]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: dwc: Fix type mismatch for kstrtou32_from_user() return value
authorHans Zhang <18255117159@163.com>
Wed, 1 Apr 2026 02:30:48 +0000 (10:30 +0800)
committerManivannan Sadhasivam <mani@kernel.org>
Thu, 2 Apr 2026 17:37:27 +0000 (23:07 +0530)
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.

Fixes: 4fbfa17f9a07 ("PCI: dwc: Add debugfs based Silicon Debug support for DWC")
Signed-off-by: Hans Zhang <18255117159@163.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260401023048.4182452-1-18255117159@163.com
drivers/pci/controller/dwc/pcie-designware-debugfs.c

index 2efddb21b2b2aad29ef96c25baabc96748fb4dd2..d0884253be97e4a5f5e2d378b7afa97f614c5ea2 100644 (file)
@@ -258,10 +258,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);
@@ -397,10 +398,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);
@@ -458,10 +460,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);