From: Roger Quadros <rogerq@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Siddharth Vadapalli <s-vadapalli@ti.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
netdev@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH 1/7] net: ethernet: ti: am65-cpsw: Don't error out in .remove()
Date: Fri, 17 Nov 2023 11:51:56 +0200 [thread overview]
Message-ID: <e8cf4f85-b05a-4a7a-ae13-406792be1bbe@kernel.org> (raw)
In-Reply-To: <20231117091655.872426-2-u.kleine-koenig@pengutronix.de>
On 17/11/2023 11:16, Uwe Kleine-König wrote:
> Returning early from .remove() with an error code still results in the
> driver unbinding the device. So the driver core ignores the returned error
> code and the resources that were not freed are never catched up. In
> combination with devm this also often results in use-after-free bugs.
>
> In case of the am65-cpsw-nuss driver there is an error path, but it's never
> taken because am65_cpts_resume() never fails (which however might be
> another problem). Still make this explicit and drop the early return in
> exchange for an error message (that is more useful than the error the
> driver core emits when .remove() returns non-zero).
>
> This prepares changing am65_cpsw_nuss_remove() to return void.
>
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index ece9f8df98ae..960cb3fa0754 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -3007,9 +3007,12 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev)
>
> common = dev_get_drvdata(dev);
>
> - ret = pm_runtime_resume_and_get(&pdev->dev);
> + ret = pm_runtime_get_sync(&pdev->dev);
Unrelated to this patch but I see pm_runtime_resume_and_get()
used at multiple places in this driver.
Would it be wise to replace them all with pm_runtime_get_sync()?
> if (ret < 0)
> - return ret;
> + /* am65_cpts_resume() doesn't fail, so handling ret < 0 is only
> + * for the sake of completeness.
> + */
> + dev_err(dev, "runtime resume failed (%pe)\n", ERR_PTR(ret));
>
> am65_cpsw_unregister_devlink(common);
> am65_cpsw_unregister_notifiers(common);
--
cheers,
-roger
next prev parent reply other threads:[~2023-11-17 9:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-17 9:16 [PATCH 0/7] net: ethernet: Convert to platform remove callback Uwe Kleine-König
2023-11-17 9:16 ` [PATCH 1/7] net: ethernet: ti: am65-cpsw: Don't error out in .remove() Uwe Kleine-König
2023-11-17 9:51 ` Roger Quadros [this message]
2023-11-17 10:39 ` Uwe Kleine-König
2023-11-18 9:53 ` Roger Quadros
2023-11-17 9:16 ` [PATCH 2/7] net: ethernet: ti: cpsw: " Uwe Kleine-König
2023-11-18 10:00 ` Roger Quadros
2023-11-18 10:05 ` Roger Quadros
2023-11-19 9:40 ` Uwe Kleine-König
2023-11-17 9:16 ` [PATCH 3/7] net: ethernet: ti: cpsw-new: " Uwe Kleine-König
2023-11-18 7:21 ` Ilias Apalodimas
2023-11-17 9:17 ` [PATCH 4/7] net: ethernet: ti: am65-cpsw: Convert to platform remove callback returning void Uwe Kleine-König
2023-11-18 10:06 ` Roger Quadros
2023-11-17 9:17 ` [PATCH 5/7] net: ethernet: ti: cpsw: " Uwe Kleine-König
2023-11-18 10:06 ` Roger Quadros
2023-11-17 9:17 ` [PATCH 6/7] net: ethernet: ti: cpsw-new: " Uwe Kleine-König
2023-11-18 10:06 ` Roger Quadros
2023-11-17 9:17 ` [PATCH 7/7] net: ethernet: ezchip: " Uwe Kleine-König
2023-11-17 9:27 ` [PATCH 0/7] net: ethernet: Convert to platform remove callback Uwe Kleine-König
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=e8cf4f85-b05a-4a7a-ae13-406792be1bbe@kernel.org \
--to=rogerq@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=kernel@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=s-vadapalli@ti.com \
--cc=u.kleine-koenig@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).