Messages in this thread | | | Date | Wed, 08 Feb 2023 08:21:58 +0100 | From | "Arnd Bergmann" <> | Subject | Re: [PATCH] habanalabs: Fix freeing uninitialized pointers |
| |
On Wed, Feb 8, 2023, at 08:05, Jiasheng Jiang wrote: > As the memory allocated by kcalloc has not been set to zero, it may > contain uninitialized pointers. > Therefore, free the non-NULL pointers may cause undefined behaviour. > > Fixes: 5574cb2194b1 ("habanalabs: Assign each CQ with its own work queue") > Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Did you run into a bug here or find that by inspection?
kcalloc() is definitely meant to return zeroed memory, so I don't see a bug here:
static inline __alloc_size(1, 2) void *kcalloc(size_t n, size_t size, gfp_t flags) { return kmalloc_array(n, size, flags | __GFP_ZERO); }
Arnd
| |