misc: bcm-vk: Fix a couple error codes in probe()
Subsystems (3)
PATCH 1/1 misc: bcm-vk: Fix a couple error codes in probe()
These errors should return negative error codes instead of returning success.
--- drivers/misc/bcm-vk/bcm_vk_dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/misc/bcm-vk/bcm_vk_dev.c +3 -1
@@ -1358,6 +1358,7 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) vk->bar[i] =pci_ioremap_bar (pdev, i *2 );if (!vk->bar[i]) {dev_err (dev,"failed to remap BAR%d\n" , i); + err = -ENOMEM ; goto err_iounmap; } }
@@ -1463,7 +1464,8 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) boot_status =vkread32 (vk,BAR_0 ,BAR_BOOT_STATUS );if (auto_load) {if ((boot_status &BOOT_STATE_MASK ) =BROM_RUNNING ) { -if (bcm_vk_trigger_autoload (vk)) + err =bcm_vk_trigger_autoload (vk); +if (err) goto err_bcm_vk_tty_exit; }else { dev_err(dev,
Signature · 1 line
2.30.0
Thanks Dan,
Quoted 2 lines · Dan Carpenter
These errors should return negative error codes instead of returning success.
Do you have a script running to report such issues or just manually reviewing to find such paths?
Quoted 4 lines
Fixes 064ffc7c3939 ("misc: bcm-vk: add autoload support")Fixes 522f692686a7 ("misc: bcm-vk: add Broadcom VK driver")Signed-off-by Dan Carpenter <[email protected]>
Quoted 26 lines
--- drivers/misc/bcm-vk/bcm_vk_dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/misc/bcm-vk/bcm_vk_dev.c +3
-1@@ -1358,6 +1358,7 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) vk->bar[i] =pci_ioremap_bar (pdev, i *2 );if (!vk->bar[i]) {dev_err (dev,"failed to remap BAR%d\n" , i); + err = -ENOMEM ; goto err_iounmap; } }@@ -1463,7 +1464,8 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent) boot_status =vkread32 (vk,BAR_0 ,BAR_BOOT_STATUS );if (auto_load) {if ((boot_status &BOOT_STATE_MASK ) =BROM_RUNNING ) { -if (bcm_vk_trigger_autoload (vk)) + err =bcm_vk_trigger_autoload (vk); +if (err) goto err_bcm_vk_tty_exit; }else { dev_err(dev,
Quoted 7 lines · Scott Branden
Thanks Dan,
Quoted 2 lines · Dan Carpenter
These errors should return negative error codes instead of returning success.
Do you have a script running to report such issues or just manually reviewing to find such paths?
Yeah. This is a new Smatch check. The heuristic is this:
<-- ret is not set within 3 lines of the goto goto label; <-- we hit a goto
return 0; <-- success path right before the cleanup block
label: <-- labels
return ret; <-- This return has to sometimes returns negatives
regards,
dan carpenter