Skip to content

Commit 44faf7e

Browse files
Hans Zhanggregkh
authored andcommitted
PCI: dwc: Fix type mismatch for kstrtou32_from_user() return value
[ Upstream commit 445588a ] 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: 4fbfa17 ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a1a24d4 commit 44faf7e

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

drivers/pci/controller/dwc/pcie-designware-debugfs.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,11 @@ static ssize_t lane_detect_write(struct file *file, const char __user *buf,
208208
struct dw_pcie *pci = file->private_data;
209209
struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
210210
u32 lane, val;
211+
int ret;
211212

212-
val = kstrtou32_from_user(buf, count, 0, &lane);
213-
if (val)
214-
return val;
213+
ret = kstrtou32_from_user(buf, count, 0, &lane);
214+
if (ret)
215+
return ret;
215216

216217
val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + SD_STATUS_L1LANE_REG);
217218
val &= ~(LANE_SELECT);
@@ -347,10 +348,11 @@ static ssize_t counter_enable_write(struct file *file, const char __user *buf,
347348
struct dw_pcie *pci = pdata->pci;
348349
struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
349350
u32 val, enable;
351+
int ret;
350352

351-
val = kstrtou32_from_user(buf, count, 0, &enable);
352-
if (val)
353-
return val;
353+
ret = kstrtou32_from_user(buf, count, 0, &enable);
354+
if (ret)
355+
return ret;
354356

355357
mutex_lock(&rinfo->reg_event_lock);
356358
set_event_number(pdata, pci, rinfo);
@@ -408,10 +410,11 @@ static ssize_t counter_lane_write(struct file *file, const char __user *buf,
408410
struct dw_pcie *pci = pdata->pci;
409411
struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
410412
u32 val, lane;
413+
int ret;
411414

412-
val = kstrtou32_from_user(buf, count, 0, &lane);
413-
if (val)
414-
return val;
415+
ret = kstrtou32_from_user(buf, count, 0, &lane);
416+
if (ret)
417+
return ret;
415418

416419
mutex_lock(&rinfo->reg_event_lock);
417420
set_event_number(pdata, pci, rinfo);

0 commit comments

Comments
 (0)