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] [day] [month] [year] [list]
Message-ID: <2998fd1e-98ed-438d-a21a-c3595a6bfc21@nvidia.com>
Date: Mon, 3 Nov 2025 11:29:40 +0000
From: Jon Hunter <jonathanh@...dia.com>
To: Ma Ke <make24@...as.ac.cn>, jckuo@...dia.com, vkoul@...nel.org,
 kishon@...nel.org, thierry.reding@...il.com, mchehab@...nel.org,
 wentong.wu@...el.com, sakari.ailus@...ux.intel.com
Cc: linux-phy@...ts.infradead.org, linux-tegra@...r.kernel.org,
 linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
 stable@...r.kernel.org
Subject: Re: [PATCH] phy: Fix error handling in tegra_xusb_pad_init


On 03/11/2025 10:30, Ma Ke wrote:
> If device_add() fails, do not use device_unregister() for error
> handling. device_unregister() consists two functions: device_del() and
> put_device(). device_unregister() should only be called after
> device_add() succeeded because device_del() undoes what device_add()
> does if successful. Change device_unregister() to put_device() call
> before returning from the function.
> 
> As comment of device_add() says, 'if device_add() succeeds, you should
> call device_del() when you want to get rid of it. If device_add() has
> not succeeded, use only put_device() to drop the reference count'.
> 
> Found by code review.
> 
> Cc: stable@...r.kernel.org
> Fixes: 78876f71b3e9 ("media: pci: intel: ivsc: Add ACE submodule")

Fixes tag is incorrect.

> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
>   drivers/phy/tegra/xusb.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> index c89df95aa6ca..d89493d68699 100644
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -171,16 +171,16 @@ int tegra_xusb_pad_init(struct tegra_xusb_pad *pad,
>   
>   	err = dev_set_name(&pad->dev, "%s", pad->soc->name);
>   	if (err < 0)
> -		goto unregister;
> +		goto put_device;

No mention in the commit message why we call put_device() here, but this 
does appear to be correct.

>   
>   	err = device_add(&pad->dev);
>   	if (err < 0)
> -		goto unregister;
> +		goto put_device;
>   
>   	return 0;
>   
> -unregister:
> -	device_unregister(&pad->dev);
> +put_device:
> +	put_device(&pad->dev);
>   	return err;
>   }
>   

-- 
nvpublic


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ