lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fkoirnlbf6szpvqubamaz77433gc5uvh6fanbaonz3znsjoxxg@7ifmlxegzzwt>
Date: Fri, 23 Jan 2026 13:10:46 +0200
From: Ioana Ciornei <ioana.ciornei@....com>
To: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org, 
	chleroy@...nel.org, Dan Carpenter <dan.carpenter@...aro.org>, 
	Su Hui <suhui@...china.com>
Subject: Re: [PATCH v2] bus: fsl-mc: fix an error handling in
 fsl_mc_device_add()

On Wed, Dec 24, 2025 at 06:44:33PM +0800, Haoxiang Li wrote:
> If device_add() fails, call put_device() to drop the device
> reference. And put_device() triggers fsl_mc_device_release()
> which does the free. Thus just return after call put_device().
> 
> Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
> Closes: https://lore.kernel.org/all/b767348e-d89c-416e-acea-1ebbff3bea20@stanley.mountain/
> Signed-off-by: Su Hui <suhui@...china.com>
> Signed-off-by: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>
> ---
> Changes in v2:
> - fix a patch error. Thanks, Christophe.
> - add specific changelog. Thanks, Dan.
> ---
>  drivers/bus/fsl-mc/fsl-mc-bus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
> index 25845c04e562..f976c5a24151 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
> @@ -896,7 +896,8 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
>  		dev_err(parent_dev,
>  			"device_add() failed for device %s: %d\n",
>  			dev_name(&mc_dev->dev), error);
> -		goto error_cleanup_dev;
> +		put_device(&mc_dev->dev);
> +		return error;


Is there any reason why you didn't go with Christophe's suggestion from
https://lore.kernel.org/all/b7f7e968-a683-4e1e-8ccc-5dd19f0f15c5@kernel.org/ ?

It's perfectly valid to call put_device() even though device_add() was
not called, meaning from the other code paths.

Ioana

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ