Re: [PATCH 5/5] EDAC/versalnet: Fix device name memory leak

From: Prasanna Kumar T S M

Date: Mon Mar 23 2026 - 03:00:43 EST




On 22-03-2026 21:45, Borislav Petkov wrote:
On Sun, Mar 22, 2026 at 06:11:49AM -0700, Prasanna Kumar T S M wrote:
The device name allocated via kzalloc() in init_one_mc() is assigned to
dev->init_name but never freed on the normal removal path.
device_register() copies init_name and then sets dev->init_name to NULL,
so the name pointer becomes unreachable from the device. Thus leaking
memory.

Track the name pointer in mc_priv and free it in remove_one_mc().

No, get rid of the name allocation and allocate a char name[MC_NAME_LEN] on the
stack in init_one_mc() which you pass into device_register(), it copies it and
we forget about it.

Sure, I will do this in v2.

Thx.