From: Simon Horman <horms@kernel.org>
To: nikhil.rao@amd.com
Cc: Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, kuba@kernel.org, brett.creeley@amd.com,
eric.joyner@amd.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, jacob.e.keller@intel.com
Subject: Re: [PATCH 1/6] pds_core: add support for quiet devcmd failures
Date: Thu, 16 Jul 2026 08:17:38 +0100 [thread overview]
Message-ID: <20260716071736.179693-3-horms@kernel.org> (raw)
In-Reply-To: <20260708212222.296202-2-nikhil.rao@amd.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev
---
--- Patch [1]: [PATCH 1/6] pds_core: add support for quiet devcmd failures ---
commit 2618e77f5d1aae31c9817f09b5056a69e237162a
Author: Brett Creeley <brett.creeley@amd.com>
pds_core: add support for quiet devcmd failures
This commit adds support to allow devcmd failure messages to be suppressed.
This will be used when adding support to negotiate
PDS_CORE_IDENTITY_VERSION_2.
> diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c
> index bded6b33289ce..dd9989cfe6b3f 100644
> --- a/drivers/net/ethernet/amd/pds_core/dev.c
> +++ b/drivers/net/ethernet/amd/pds_core/dev.c
[ ... ]
> @@ -197,7 +199,7 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,
>
> memcpy_toio(&pdsc->cmd_regs->cmd, cmd, sizeof(*cmd));
> pdsc_devcmd_dbell(pdsc);
> - err = pdsc_devcmd_wait(pdsc, cmd->opcode, max_seconds);
> + err = __pdsc_devcmd_wait(pdsc, cmd->opcode, max_seconds, do_msg);
>
> if ((err == -ENXIO || err == -ETIMEDOUT) && pdsc->wq)
> queue_work(pdsc->wq, &pdsc->health_work);
[Severity: High]
This is a pre-existing issue, but does this error path trigger a
use-after-free during device removal?
During device removal, pdsc_remove() destroys the workqueue without clearing
the pointer before invoking pdsc_teardown():
pdsc_remove() {
...
if (pdsc->wq)
destroy_workqueue(pdsc->wq);
mutex_lock(&pdsc->config_lock);
set_bit(PDSC_S_STOPPING_DRIVER, &pdsc->state);
pdsc_stop(pdsc);
pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING);
...
}
The teardown function issues a hardware reset command via pdsc_devcmd_reset().
If the device is unresponsive and the command times out, the error path here in
__pdsc_devcmd_locked() catches the -ETIMEDOUT error.
Because pdsc->wq was left as a dangling pointer, the condition evaluates to true
and execution falls through to queue_work(), which will dereference the already
destroyed workqueue pointer.
Could the pdsc->wq pointer be set to NULL immediately after destruction to
prevent this, or should the teardown sequence be reordered?
> else
> memcpy_fromio(comp, &pdsc->cmd_regs->comp, sizeof(*comp));
>
> if (err != -ETIMEDOUT && err != -EAGAIN)
> pdsc_deferred_dma_free(pdsc);
>
> return err;
> }
next prev parent reply other threads:[~2026-07-16 7:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 21:22 [PATCH net-next v7 0/6] pds_core: Add PLDM firmware update and host backed memory support Nikhil P. Rao
2026-07-08 21:22 ` [PATCH 1/6] pds_core: add support for quiet devcmd failures Nikhil P. Rao
2026-07-16 7:17 ` Simon Horman [this message]
2026-07-08 21:22 ` [PATCH 2/6] pds_core: add support for identity version 2 Nikhil P. Rao
2026-07-08 21:22 ` [PATCH 3/6] pds_core: add PLDM firmware update support via devlink flash Nikhil P. Rao
2026-07-16 7:20 ` Simon Horman
2026-07-08 21:22 ` [PATCH 4/6] pds_core: add PLDM component info display Nikhil P. Rao
2026-07-16 7:22 ` Simon Horman
2026-07-08 21:22 ` [PATCH 5/6] pds_core: add host backed memory support for firmware Nikhil P. Rao
2026-07-16 7:23 ` Simon Horman
2026-07-16 7:23 ` Simon Horman
2026-07-08 21:22 ` [PATCH 6/6] pds_core: add debugfs support for host backed memory Nikhil P. Rao
-- strict thread matches above, loose matches on Subject: below --
2026-04-29 7:58 [PATCH 0/6] pds_core: Add PLDM firmware update and host backed memory support Nikhil P. Rao
2026-04-29 7:58 ` [PATCH 1/6] pds_core: add support for quiet devcmd failures Nikhil P. Rao
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=20260716071736.179693-3-horms@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.joyner@amd.com \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikhil.rao@amd.com \
--cc=pabeni@redhat.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