Re: [PATCH] driver core: Fix an uninitialized variable is used by __device_attach()

Dmitry Torokhov
2024-08-23T00:02:53Z

Hi,

On Fri, Aug 23, 2024 at 07:46:09AM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.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.

There is no issue here.

Thanks.

--
Dmitry