2023-09-19 22:18:06

by Nick Desaulniers

[permalink] [raw]
Subject: -Wuninitialized in drivers/accel/habanalabs/common/memory.c introduced by aa7b6367186e

commit aa7b6367186e ("accel/habanalabs: tiny refactor of hl_map_dmabuf()")

introduced a warning that's breaking the build in linux-next.

drivers/accel/habanalabs/common/memory.c:1735:11: error: variable
'hdev' is uninitialized when used here [-Werror,-Wuninitialized]
317 1735 | dev_dbg(hdev->dev, "Failed to map dmabuf because p2p is disabled\n");
318 | ^~~~
319/builds/linux/include/linux/dev_printk.h:155:18: note: expanded
from macro 'dev_dbg'
320 155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
321 | ^~~
322/builds/linux/include/linux/dynamic_debug.h:274:7: note: expanded
from macro 'dynamic_dev_dbg'
323 274 | dev, fmt, ##__VA_ARGS__)
324 | ^~~
325/builds/linux/include/linux/dynamic_debug.h:250:59: note: expanded
from macro '_dynamic_func_call'
326 250 | _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__)
327 | ^~~~~~~~~~~
328/builds/linux/include/linux/dynamic_debug.h:248:65: note: expanded
from macro '_dynamic_func_call_cls'
329 248 | __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func,
##__VA_ARGS__)
330 | ^~~~~~~~~~~
331/builds/linux/include/linux/dynamic_debug.h:224:15: note: expanded
from macro '__dynamic_func_call_cls'
332 224 | func(&id, ##__VA_ARGS__); \
333 | ^~~~~~~~~~~
334/builds/linux/drivers/accel/habanalabs/common/memory.c:1731:24:
note: initialize the variable 'hdev' to silence this warning
335 1731 | struct hl_device *hdev;
336 | ^
337 | = NULL


Please fix. Also, please post your patches to LKML so people can post
info like this in response directly to your patch. I could not find
aa7b6367186e on lore.
--
Thanks,
~Nick Desaulniers


2023-09-20 18:34:56

by Tomer Tayar

[permalink] [raw]
Subject: Re: -Wuninitialized in drivers/accel/habanalabs/common/memory.c introduced by aa7b6367186e

On 20/09/2023 0:01, Nick Desaulniers wrote:
> commit aa7b6367186e ("accel/habanalabs: tiny refactor of hl_map_dmabuf()")
>
> introduced a warning that's breaking the build in linux-next.
>
> drivers/accel/habanalabs/common/memory.c:1735:11: error: variable
> 'hdev' is uninitialized when used here [-Werror,-Wuninitialized]
> 317 1735 | dev_dbg(hdev->dev, "Failed to map dmabuf because p2p is disabled\n");
> 318 | ^~~~
> 319/builds/linux/include/linux/dev_printk.h:155:18: note: expanded
> from macro 'dev_dbg'
> 320 155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
> 321 | ^~~
> 322/builds/linux/include/linux/dynamic_debug.h:274:7: note: expanded
> from macro 'dynamic_dev_dbg'
> 323 274 | dev, fmt, ##__VA_ARGS__)
> 324 | ^~~
> 325/builds/linux/include/linux/dynamic_debug.h:250:59: note: expanded
> from macro '_dynamic_func_call'
> 326 250 | _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__)
> 327 | ^~~~~~~~~~~
> 328/builds/linux/include/linux/dynamic_debug.h:248:65: note: expanded
> from macro '_dynamic_func_call_cls'
> 329 248 | __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func,
> ##__VA_ARGS__)
> 330 | ^~~~~~~~~~~
> 331/builds/linux/include/linux/dynamic_debug.h:224:15: note: expanded
> from macro '__dynamic_func_call_cls'
> 332 224 | func(&id, ##__VA_ARGS__); \
> 333 | ^~~~~~~~~~~
> 334/builds/linux/drivers/accel/habanalabs/common/memory.c:1731:24:
> note: initialize the variable 'hdev' to silence this warning
> 335 1731 | struct hl_device *hdev;
> 336 | ^
> 337 | = NULL
>
>
> Please fix. Also, please post your patches to LKML so people can post
> info like this in response directly to your patch. I could not find
> aa7b6367186e on lore.
> --
> Thanks,
> ~Nick Desaulniers

Thanks Nick, we will send a fix for it.