From: Dan Carpenter <error27@gmail.com>
To: Alexandru Hossu <hossu.alexandru@gmail.com>
Cc: linux-tegra@vger.kernel.org, marvin24@gmx.de,
gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] staging: nvec: fix pm_power_off teardown in tegra_nvec_remove()
Date: Mon, 13 Apr 2026 11:21:40 +0300 [thread overview]
Message-ID: <adynlKves3yAAcCA@stanley.mountain> (raw)
In-Reply-To: <20260412205117.387125-2-hossu.alexandru@gmail.com>
On Sun, Apr 12, 2026 at 10:51:17PM +0200, Alexandru Hossu wrote:
> The remove() function unconditionally sets pm_power_off to NULL regardless
> of whether this driver instance was the one that set it. There is even a
> FIXME comment acknowledging this. Additionally, nvec_power_handle is never
> cleared on removal, leaving a dangling pointer to freed device data.
>
> Fix both issues: check that pm_power_off still points to nvec_power_off
> before clearing it, and also clear nvec_power_handle at the same time.
>
> Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
> ---
> drivers/staging/nvec/nvec.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 75877038847f..9fe9b7a3491d 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -907,8 +907,10 @@ static void tegra_nvec_remove(struct platform_device *pdev)
> nvec_unregister_notifier(nvec, &nvec->nvec_status_notifier);
> cancel_work_sync(&nvec->rx_work);
> cancel_work_sync(&nvec->tx_work);
> - /* FIXME: needs check whether nvec is responsible for power off */
> - pm_power_off = NULL;
> + if (pm_power_off == nvec_power_off) {
> + pm_power_off = NULL;
> + nvec_power_handle = NULL;
> + }
Linux power off handling is a known mess...
I wonder why the original added a comment instead of a test? To me
checking for if if (pm_power_off == nvec_power_off) makes sense and I
can't see how it would hurt anything.
At this point, we're unloading the driver so nvec_power_handle is
about to be freed. Is there any benefit to setting it to NULL?
regards,
dan carpenter
next prev parent reply other threads:[~2026-04-13 8:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 20:51 [PATCH 3/5] staging: nvec: fix use-after-free in nvec_rx_completed() Alexandru Hossu
2026-04-12 20:51 ` [PATCH 4/5] staging: nvec: fix pm_power_off teardown in tegra_nvec_remove() Alexandru Hossu
2026-04-13 8:21 ` Dan Carpenter [this message]
2026-04-13 8:08 ` [PATCH 3/5] staging: nvec: fix use-after-free in nvec_rx_completed() Dan Carpenter
[not found] <20260412205057.386856-4-hossu.alexandru@gmail.com>
2026-04-13 10:02 ` [PATCH 4/5] staging: nvec: fix pm_power_off teardown in tegra_nvec_remove() Alexandru Hossu
2026-04-13 10:25 ` Dan Carpenter
2026-04-13 10:39 ` Dan Carpenter
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=adynlKves3yAAcCA@stanley.mountain \
--to=error27@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hossu.alexandru@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=marvin24@gmx.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