From: "Rao, Nikhil" <nikhirao@amd.com>
To: Simon Horman <horms@kernel.org>
Cc: 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,
nikhil.rao@amd.com
Subject: Re: [PATCH 1/6] pds_core: add support for quiet devcmd failures
Date: Sat, 18 Jul 2026 15:21:07 -0700 [thread overview]
Message-ID: <d88d1a0b-cc57-42aa-b2b3-7cab15f57ae3@amd.com> (raw)
In-Reply-To: <20260716071736.179693-3-horms@kernel.org>
On 7/16/2026 12:17 AM, Simon Horman wrote:
> 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;
>> }
Fixed in [1] by reordering destroy_workqueue() after pdsc_teardown().
Thanks,
Nikhil
[1]
https://lore.kernel.org/netdev/20260714180223.1642792-3-nikhil.rao@amd.com/
next prev parent reply other threads:[~2026-07-18 22:21 UTC|newest]
Thread overview: 17+ 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
2026-07-18 22:21 ` Rao, Nikhil [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-18 22:34 ` Rao, Nikhil
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-18 23:06 ` Rao, Nikhil
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-18 23:16 ` Rao, Nikhil
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=d88d1a0b-cc57-42aa-b2b3-7cab15f57ae3@amd.com \
--to=nikhirao@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.joyner@amd.com \
--cc=horms@kernel.org \
--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