[PATCH] release region in skfddi driver

From: Felipe W Damasio
Date: Mon Oct 06 2003 - 08:12:34 EST


Hi Jeff/Christoph,

Patch against 2.6.0-test6.

- Check the return value of request_region;

- Only increment the global adapter value if request_region returned a valid pointer;

- release_region if global adapter value > 0;

Found by smatch.

Please review and consider applying,

Cheers.

Felipe --- linux-2.6.0-test6/drivers/net/skfp/skfddi.c.orig 2003-10-06 09:47:16.000000000 -0300
+++ linux-2.6.0-test6/drivers/net/skfp/skfddi.c 2003-10-06 10:03:14.000000000 -0300
@@ -394,11 +394,15 @@
skb_queue_head_init(&smc->os.SendSkbQueue);

if (skfp_driver_init(dev) == 0) {
+ if (!request_region(dev->base_addr,
+ FP_IO_LEN, dev->name)){
+ kfree (dev);
+ return -EBUSY;
+ }
+
// only increment global board
// count on success
num_boards++;
- request_region(dev->base_addr,
- FP_IO_LEN, dev->name);
if ((SubSysId & 0xff00) == 0x5500 ||
(SubSysId & 0xff00) == 0x5800) {
printk("%s: SysKonnect FDDI PCI adapter"
@@ -411,11 +415,8 @@
} else {
kfree(dev);
i = SKFP_MAX_NUM_BOARDS; // stop search
-
}
-
} // if (dev != NULL)
-
} // for SKFP_MAX_NUM_BOARDS

/*
@@ -427,6 +428,7 @@
if (num_boards > 0)
return (0);
else {
+ release_region (dev->base_addr, FP_IO_LEN);
printk("no SysKonnect FDDI adapter found\n");
return (-ENODEV);
}