Fix a potential NULL pointer dereference in free_shared_mem() in drivers/net/s2io.c
authorMicah Gruber <micah.gruber@gmail.com>
Mon, 9 Jul 2007 03:29:04 +0000 (11:29 +0800)
committerJeff Garzik <jeff@garzik.org>
Mon, 16 Jul 2007 21:56:00 +0000 (17:56 -0400)
This patch fixes a potential null dereference bug where we dereference
nic before a null check. This patch simply moves the dereferencing
after the null check.

Signed-off-by: Micah Gruber < micah.gruber@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/s2io.c

index fa29a403a247a8bfc2146651c273657bbf3a7e72..7d549355815a3d4f1dafe494d6c4bedce1a598b2 100644 (file)
@@ -796,12 +796,14 @@ static void free_shared_mem(struct s2io_nic *nic)
        struct mac_info *mac_control;
        struct config_param *config;
        int lst_size, lst_per_page;
-       struct net_device *dev = nic->dev;
+       struct net_device *dev;
        int page_num = 0;
 
        if (!nic)
                return;
 
+       dev = nic->dev;
+
        mac_control = &nic->mac_control;
        config = &nic->config;