Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dan Carpenter" <error27@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: dwc: Fix signedness bug in fault injection test code
Date: Wed, 13 May 2026 20:19:02 +0000	[thread overview]
Message-ID: <20260513201903.71E6DC19425@smtp.kernel.org> (raw)
In-Reply-To: <agL-Uwfn26SI4Gb0@stanley.mountain>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Register accesses without ensuring active power state (missing pm_runtime).
--

commit 4899a9300a95dd54caf44bf07153849d88f68ae7
Author: Dan Carpenter <error27@gmail.com>

PCI: dwc: Fix signedness bug in fault injection test code

This commit fixes a signedness bug in the fault injection debugfs handler.
It ensures that negative error codes from kstrtou32 are properly handled by
storing the return value in an int instead of a u32.

> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> index d0884253be97e..4bfc1748f2d73 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
[ ... ]
> @@ -327,10 +328,10 @@ static ssize_t err_inj_write(struct file *file, const char __user *buf,
>  			return -EINVAL;
>  		}
>  	} else {
> -		val = kstrtou32(kern_buf, 0, &counter);
> -		if (val) {
> +		ret = kstrtou32(kern_buf, 0, &counter);
> +		if (ret) {
>  			kfree(kern_buf);
> -			return val;
> +			return ret;
>  		}
>  	}

This isn't a regression introduced by this commit, but is it safe to access
the hardware registers immediately after this block without ensuring the
device is in an active power state?

This function handles user writes to debugfs, which can happen at any time.
If the PCIe controller is runtime-suspended, accessing its memory-mapped
registers via dw_pcie_readl_dbi() might cause a bus hang or kernel panic.

Would it make sense to call pm_runtime_get_sync() before interacting with
the hardware registers later in this function?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/agL-Uwfn26SI4Gb0@stanley.mountain?part=1

      parent reply	other threads:[~2026-05-13 20:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 10:17 [PATCH] PCI: dwc: Fix signedness bug in fault injection test code Dan Carpenter
2026-05-12 10:40 ` Hans Zhang
2026-05-13 20:19 ` sashiko-bot [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=20260513201903.71E6DC19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=error27@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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