Re: [PATCH v4] node: fix error handling in node_init_node_access
From: Greg KH
Date: Mon Jun 27 2022 - 09:26:50 EST
On Wed, Jun 22, 2022 at 01:16:23AM +0800, Zhi Song wrote:
> dev_set_name() allocates new space to dev->name if it allocates
> successfully. But if we failed to allocate space, there won't be any
> new space for dev->name. Therefore, there's no need for calling
> kfree_const(dev->kobj.name) in dev_set_name()'s error handling.
Can you actually trigger a failure in dev_set_name()? I ask as we don't
seem to check this anywhere in the driver core, and we should either
just not care (as it really can not fail), or fix up all instances of
that failure.
> If we failed to calling device_register(dev), we just need to call
> put_device(dev) which will do access_node freeing, kobj.name freeing
> and other cleanup.
That is a separate issue, and should be a separate change, right?
thanks,
greg k-h