From: Jon Hunter <jonathanh@nvidia.com>
To: Ma Ke <make24@iscas.ac.cn>,
jckuo@nvidia.com, vkoul@kernel.org, kishon@kernel.org,
thierry.reding@gmail.com, mchehab@kernel.org,
wentong.wu@intel.com, sakari.ailus@linux.intel.com
Cc: linux-phy@lists.infradead.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
stable@vger.kernel.org
Subject: Re: [PATCH] phy: Fix error handling in tegra_xusb_pad_init
Date: Mon, 3 Nov 2025 11:29:40 +0000 [thread overview]
Message-ID: <2998fd1e-98ed-438d-a21a-c3595a6bfc21@nvidia.com> (raw)
In-Reply-To: <20251103103038.8193-1-make24@iscas.ac.cn>
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@vger.kernel.org
> Fixes: 78876f71b3e9 ("media: pci: intel: ivsc: Add ACE submodule")
Fixes tag is incorrect.
> Signed-off-by: Ma Ke <make24@iscas.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
prev parent reply other threads:[~2025-11-03 11:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 10:30 Ma Ke
2025-11-03 11:29 ` Jon Hunter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2998fd1e-98ed-438d-a21a-c3595a6bfc21@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=jckuo@nvidia.com \
--cc=kishon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=vkoul@kernel.org \
--cc=wentong.wu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®