]> err.no Git - linux-2.6/commitdiff
ieee1394: sbp2: fix sbp2_remove_device for error cases
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Sat, 11 Aug 2007 09:51:16 +0000 (11:51 +0200)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Sat, 25 Aug 2007 16:00:26 +0000 (18:00 +0200)
Bug found by Olaf Hering <olh@suse.de>:
sbp2util_remove_command_orb_pool requires a valid lu->hi pointer.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
drivers/ieee1394/sbp2.c

index 47dbe8f17e8210cabe7b87254b7ba1ac329a1c9d..a81ba8fca0db168314a2ce21aee0cecb0fd4f567 100644 (file)
@@ -513,9 +513,9 @@ static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu)
        return 0;
 }
 
-static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu)
+static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu,
+                                            struct hpsb_host *host)
 {
-       struct hpsb_host *host = lu->hi->host;
        struct list_head *lh, *next;
        struct sbp2_command_info *cmd;
        unsigned long flags;
@@ -922,15 +922,16 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
 
        if (!lu)
                return;
-
        hi = lu->hi;
+       if (!hi)
+               goto no_hi;
 
        if (lu->shost) {
                scsi_remove_host(lu->shost);
                scsi_host_put(lu->shost);
        }
        flush_scheduled_work();
-       sbp2util_remove_command_orb_pool(lu);
+       sbp2util_remove_command_orb_pool(lu, hi->host);
 
        list_del(&lu->lu_list);
 
@@ -971,9 +972,8 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
 
        lu->ud->device.driver_data = NULL;
 
-       if (hi)
-               module_put(hi->host->driver->owner);
-
+       module_put(hi->host->driver->owner);
+no_hi:
        kfree(lu);
 }