Bug 195785

Summary: Possible unintended usage of "p" variable
Product: Drivers Reporter: Petru-Florin Mihancea (petrum)
Component: OtherAssignee: James Simmons (jsimmons)
Status: NEW ---    
Severity: normal CC: tj
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.12-rc1 Subsystem:
Regression: No Bisected commit-id:

Description Petru-Florin Mihancea 2017-05-16 07:50:25 UTC
Hi,

While experimenting with a CodeSonar plugin we develop, we noticed a potential bug in file "drivers/ata/libata-core.c" line 6803:

force_ent->port = simple_strtoul(id, &endp, 10);
if (p == endp || *endp != '\0') { 

In the first check of the if statement, shouldn't the "id" variable be checked (instead of "p")? As can be observed, the proper conversion of "id" should be verified.
Comment 1 Tejun Heo 2017-05-31 17:17:49 UTC
Indeed. Care to submit a patch?
Comment 2 Petru-Florin Mihancea 2017-05-31 18:14:46 UTC
No, thanks for asking :). You can fix it directly. Thanks again.