* [PATCH] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value
@ 2026-04-01 2:30 Hans Zhang
2026-04-01 12:27 ` Manivannan Sadhasivam
2026-04-02 17:38 ` Manivannan Sadhasivam
0 siblings, 2 replies; 4+ messages in thread
From: Hans Zhang @ 2026-04-01 2:30 UTC (permalink / raw)
To: lpieralisi, jingoohan1, mani, kwilczynski, bhelgaas
Cc: robh, linux-pci, linux-kernel, Hans Zhang
kstrtou32_from_user() returns int, but the return value was stored in
a u32 variable 'val', risking sign loss. Use a dedicated int variable
to correctly handle the return code.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
.../controller/dwc/pcie-designware-debugfs.c | 21 +++++++++++--------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
index 0d1340c9b364..9461be074490 100644
--- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
+++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
@@ -208,10 +208,11 @@ static ssize_t lane_detect_write(struct file *file, const char __user *buf,
struct dw_pcie *pci = file->private_data;
struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
u32 lane, val;
+ int ret;
- val = kstrtou32_from_user(buf, count, 0, &lane);
- if (val)
- return val;
+ ret = kstrtou32_from_user(buf, count, 0, &lane);
+ if (ret)
+ return ret;
val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + SD_STATUS_L1LANE_REG);
val &= ~(LANE_SELECT);
@@ -347,10 +348,11 @@ static ssize_t counter_enable_write(struct file *file, const char __user *buf,
struct dw_pcie *pci = pdata->pci;
struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
u32 val, enable;
+ int ret;
- val = kstrtou32_from_user(buf, count, 0, &enable);
- if (val)
- return val;
+ ret = kstrtou32_from_user(buf, count, 0, &enable);
+ if (ret)
+ return ret;
mutex_lock(&rinfo->reg_event_lock);
set_event_number(pdata, pci, rinfo);
@@ -408,10 +410,11 @@ static ssize_t counter_lane_write(struct file *file, const char __user *buf,
struct dw_pcie *pci = pdata->pci;
struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
u32 val, lane;
+ int ret;
- val = kstrtou32_from_user(buf, count, 0, &lane);
- if (val)
- return val;
+ ret = kstrtou32_from_user(buf, count, 0, &lane);
+ if (ret)
+ return ret;
mutex_lock(&rinfo->reg_event_lock);
set_event_number(pdata, pci, rinfo);
base-commit: 9147566d801602c9e7fc7f85e989735735bf38ba
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value
2026-04-01 2:30 [PATCH] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value Hans Zhang
@ 2026-04-01 12:27 ` Manivannan Sadhasivam
2026-04-01 14:01 ` Hans Zhang
2026-04-02 17:38 ` Manivannan Sadhasivam
1 sibling, 1 reply; 4+ messages in thread
From: Manivannan Sadhasivam @ 2026-04-01 12:27 UTC (permalink / raw)
To: Hans Zhang
Cc: lpieralisi, jingoohan1, kwilczynski, bhelgaas, robh, linux-pci,
linux-kernel
On Wed, Apr 01, 2026 at 10:30:48AM +0800, Hans Zhang wrote:
> kstrtou32_from_user() returns int, but the return value was stored in
> a u32 variable 'val', risking sign loss. Use a dedicated int variable
> to correctly handle the return code.
>
> Signed-off-by: Hans Zhang <18255117159@163.com>
Can you add Fixes tag also?
- Mani
> ---
> .../controller/dwc/pcie-designware-debugfs.c | 21 +++++++++++--------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> index 0d1340c9b364..9461be074490 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> @@ -208,10 +208,11 @@ static ssize_t lane_detect_write(struct file *file, const char __user *buf,
> struct dw_pcie *pci = file->private_data;
> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> u32 lane, val;
> + int ret;
>
> - val = kstrtou32_from_user(buf, count, 0, &lane);
> - if (val)
> - return val;
> + ret = kstrtou32_from_user(buf, count, 0, &lane);
> + if (ret)
> + return ret;
>
> val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + SD_STATUS_L1LANE_REG);
> val &= ~(LANE_SELECT);
> @@ -347,10 +348,11 @@ static ssize_t counter_enable_write(struct file *file, const char __user *buf,
> struct dw_pcie *pci = pdata->pci;
> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> u32 val, enable;
> + int ret;
>
> - val = kstrtou32_from_user(buf, count, 0, &enable);
> - if (val)
> - return val;
> + ret = kstrtou32_from_user(buf, count, 0, &enable);
> + if (ret)
> + return ret;
>
> mutex_lock(&rinfo->reg_event_lock);
> set_event_number(pdata, pci, rinfo);
> @@ -408,10 +410,11 @@ static ssize_t counter_lane_write(struct file *file, const char __user *buf,
> struct dw_pcie *pci = pdata->pci;
> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> u32 val, lane;
> + int ret;
>
> - val = kstrtou32_from_user(buf, count, 0, &lane);
> - if (val)
> - return val;
> + ret = kstrtou32_from_user(buf, count, 0, &lane);
> + if (ret)
> + return ret;
>
> mutex_lock(&rinfo->reg_event_lock);
> set_event_number(pdata, pci, rinfo);
>
> base-commit: 9147566d801602c9e7fc7f85e989735735bf38ba
> --
> 2.34.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value
2026-04-01 12:27 ` Manivannan Sadhasivam
@ 2026-04-01 14:01 ` Hans Zhang
0 siblings, 0 replies; 4+ messages in thread
From: Hans Zhang @ 2026-04-01 14:01 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: lpieralisi, jingoohan1, kwilczynski, bhelgaas, robh, linux-pci,
linux-kernel
On 4/1/26 20:27, Manivannan Sadhasivam wrote:
> On Wed, Apr 01, 2026 at 10:30:48AM +0800, Hans Zhang wrote:
>> kstrtou32_from_user() returns int, but the return value was stored in
>> a u32 variable 'val', risking sign loss. Use a dedicated int variable
>> to correctly handle the return code.
>>
>> Signed-off-by: Hans Zhang <18255117159@163.com>
>
> Can you add Fixes tag also?
>
Hi Mani,
Sorry, below is the "Fixes" tag that I found. Could it be that you added
it when receiving the patch? Or do I need to send the v2 version?
Fixes: 4fbfa17f9a07 ("PCI: dwc: Add debugfs based Silicon Debug support
for DWC")
Best regards,
Hans
> - Mani
>
>> ---
>> .../controller/dwc/pcie-designware-debugfs.c | 21 +++++++++++--------
>> 1 file changed, 12 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> index 0d1340c9b364..9461be074490 100644
>> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> @@ -208,10 +208,11 @@ static ssize_t lane_detect_write(struct file *file, const char __user *buf,
>> struct dw_pcie *pci = file->private_data;
>> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>> u32 lane, val;
>> + int ret;
>>
>> - val = kstrtou32_from_user(buf, count, 0, &lane);
>> - if (val)
>> - return val;
>> + ret = kstrtou32_from_user(buf, count, 0, &lane);
>> + if (ret)
>> + return ret;
>>
>> val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + SD_STATUS_L1LANE_REG);
>> val &= ~(LANE_SELECT);
>> @@ -347,10 +348,11 @@ static ssize_t counter_enable_write(struct file *file, const char __user *buf,
>> struct dw_pcie *pci = pdata->pci;
>> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>> u32 val, enable;
>> + int ret;
>>
>> - val = kstrtou32_from_user(buf, count, 0, &enable);
>> - if (val)
>> - return val;
>> + ret = kstrtou32_from_user(buf, count, 0, &enable);
>> + if (ret)
>> + return ret;
>>
>> mutex_lock(&rinfo->reg_event_lock);
>> set_event_number(pdata, pci, rinfo);
>> @@ -408,10 +410,11 @@ static ssize_t counter_lane_write(struct file *file, const char __user *buf,
>> struct dw_pcie *pci = pdata->pci;
>> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>> u32 val, lane;
>> + int ret;
>>
>> - val = kstrtou32_from_user(buf, count, 0, &lane);
>> - if (val)
>> - return val;
>> + ret = kstrtou32_from_user(buf, count, 0, &lane);
>> + if (ret)
>> + return ret;
>>
>> mutex_lock(&rinfo->reg_event_lock);
>> set_event_number(pdata, pci, rinfo);
>>
>> base-commit: 9147566d801602c9e7fc7f85e989735735bf38ba
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value
2026-04-01 2:30 [PATCH] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value Hans Zhang
2026-04-01 12:27 ` Manivannan Sadhasivam
@ 2026-04-02 17:38 ` Manivannan Sadhasivam
1 sibling, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2026-04-02 17:38 UTC (permalink / raw)
To: lpieralisi, jingoohan1, kwilczynski, bhelgaas, Hans Zhang
Cc: robh, linux-pci, linux-kernel
On Wed, 01 Apr 2026 10:30:48 +0800, Hans Zhang wrote:
> kstrtou32_from_user() returns int, but the return value was stored in
> a u32 variable 'val', risking sign loss. Use a dedicated int variable
> to correctly handle the return code.
Applied, thanks!
[1/1] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value
commit: 445588a3b18bb0702d746cb61f7a443639027651
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-02 17:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-01 2:30 [PATCH] PCI: dwc: Fix type mismatch for kstrtou32_from_user return value Hans Zhang
2026-04-01 12:27 ` Manivannan Sadhasivam
2026-04-01 14:01 ` Hans Zhang
2026-04-02 17:38 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®