Bug 188931 - Function hfc4s8s_probe() does not set error code when the call to request_region() fails
Summary: Function hfc4s8s_probe() does not set error code when the call to request_reg...
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: ISDN (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_isdn
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 11:09 UTC by bianpan
Modified: 2017-05-12 00:11 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
The patch fixes the bug (1.02 KB, patch)
2017-05-12 00:11 UTC, bianpan
Details | Diff

Description bianpan 2016-11-25 11:09:38 UTC
Function request_region() returns a NULL pointer on failures. In the function hfc4s8s_probe() defined in file drivers/isdn/hisax/hfc4s8s_l1.c, it is called and its return value is checked against NULL. When the return value is NULL, the control flow jumps to label "out" and returns variable err. However, the value of variable err is 0. The check of err at line 1484 guarantees that the value of err must be 0 when request_region() is called. As a result, hfc4s8s_probe() will return 0 (indicates success) even if request_region() fails. Maybe it is better to explicitly assign "-ENOMEM" to err when request_region() returns a NULL pointer. Codes and comments related to this bug are summarised as below.

hfc4s8s_probe @@ drivers/isdn/hisax/hfc4s8s_l1.c
1469 static int
1470 hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1471 {
1472     int err = -ENOMEM;
         ...
1482     err = pci_enable_device(pdev);
1483 
1484     if (err)
1485         goto out;
         ...
1498     if (!request_region(hw->iobase, 8, hw->card_name)) {
1499         printk(KERN_INFO
1500                "HFC-4S/8S: failed to request address space at 0x%04x\n",
1501                hw->iobase);
             // insert "err = -ENOMEM;" here?
1502         goto out;
1503     }
         ...
1511 out:
1512     kfree(hw);
1513     return (err);
1514 }

Thanks very much!
Comment 1 bianpan 2017-05-12 00:11:36 UTC
Created attachment 256437 [details]
The patch fixes the bug

The patch has been merged into the latest version of the Linux kernel. So I will close the bug.

Note You need to log in before you can comment on or make changes to this bug.