[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <15769558-010a-4935-ae0c-b4da6dfb8203@icloud.com>
Date: Fri, 23 Aug 2024 19:03:54 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, linux-kernel@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>, stable@...r.kernel.org
Subject: Re: [PATCH] driver core: Fix an uninitialized variable is used by
__device_attach()
On 2024/8/23 08:02, Dmitry Torokhov wrote:
> Hi,
>
> On Fri, Aug 23, 2024 at 07:46:09AM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@...cinc.com>
>>
>> An uninitialized variable @data.have_async may be used as analyzed
>> by the following inline comments:
>>
>> static int __device_attach(struct device *dev, bool allow_async)
>> {
>> // if @allow_async is true.
>>
>> ...
>> struct device_attach_data data = {
>> .dev = dev,
>> .check_async = allow_async,
>> .want_async = false,
>> };
>> // @data.have_async is not initialized.
>
> No, in the presence of a structure initializer fields not explicitly
> initialized will be set to 0 by the compiler.
>
yes. you are right. compiler will implicitly initialize @data.have_async.
is it worthy to explicitly initialize @data.have_async as existing
@data.want_async as well to prevent misleading human readers since this
initialization approach appears to partial initialization ?
> There is no issue here.
>
> Thanks.
>
Powered by blists - more mailing lists