Skip to contentSkip to conversation

request_region() return value missing check

PATCH In review Laurent Wandrebeck 2 participants 2 messages Mar 17, 2006 – Apr 29, 2006 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 request_region() return value missing check

Hi,
Here is a simple patch against 2.6.16-rc6-git8.
Is adds checks about return value for two request_region() in drivers/net/hamradio/scc.c. Please CC me on replies.
Regards.

drivers/net/hamradio/scc.c 2006-03-17 13:09:38.000000000 +0100 renamed from drivers/net/hamradio/scc.c.ori 2006-03-17 13:11:52.000000000 +0100 +10 -2
@@ -1815,8 +1815,16 @@ static int scc_net_ioctl(struct net_devi
 
                                if (found)
                                {
-                                       request_region(SCC_Info[2*Nchips+chan].ctrl, 1, "scc ctrl");
-                                       request_region(SCC_Info[2*Nchips+chan].data, 1, "scc data");
+                                       if (!request_region(SCC_Info[2*Nchips+chan].ctrl, 1, "scc ctrl")) {
+                                           printk(KERN_ERR "scc: unable to reserve region %d for scc ctrl\n",
+                                                            SCC_Info[2*Nchips+chan].ctrl);
+                                           return -EBUSY;
+                                       }
+                                       if (!request_region(SCC_Info[2*Nchips+chan].data, 1, "scc data")) {
+                                           printk(KERN_ERR "scc: unable to reserve region %d for scc data\n",
+                                                            SCC_Info[2*Nchips+chan].data);
+                                           return -EBUSY;
+                                       }
 
                                        if (Nchips+chan != 0 &&
                                            scc_net_alloc(device_name,
#1 lore raw
Quoted 2 lines · Laurent Wandrebeck

Here is a simple patch against 2.6.16-rc6-git8.
Is adds checks about return value for two request_region() in drivers/net/hamradio/scc.c.

Several things:

o Your mailer garbles patches, so I couldn't apply it anymore.
o If the second request_region your patches will abort initialization leaving the first one region allocated.
o The potencial abort happens in a loop so if we abort anytime other than during the first iteration the resources will stay allocated and the driver won't drive instances found earlier.

Thanks,

Ralf