]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] bug fix for free list handling
authorAlan D. Brunelle <Alan.Brunelle@hp.com>
Tue, 29 Apr 2008 20:12:51 +0000 (16:12 -0400)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 30 Apr 2008 00:37:32 +0000 (19:37 -0500)
commit:

commit 542bd1377a963070bc4a03ff7d2690ddf3920596
Author: James Bottomley <James.Bottomley@HansenPartnership.com>
Date:   Mon Apr 21 10:57:20 2008 -0500

    [SCSI] fix SLUB WARN_ON

Fixed another problem in free list handling by moving list allocation
from scsi_host_alloc() to scsi_add_host().  Unfortunately it
introduced a new failure mode in that hosts can pass straight from
alloc to put without going through add, leaving the free list
uninitialised.

Fix by checking shost->cmd_pool on the release path to see if it got
initialised.

Signed-off-by: Alan D. Brunelle <alan.brunelle@hp.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/scsi.c

index 12d69d7c85775475ce89de8fc6a6381ba4453809..749c9c7fc2e1ae3db016a9eafcbdc791960997bf 100644 (file)
@@ -469,6 +469,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
        cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask);
        if (!cmd) {
                scsi_put_host_cmd_pool(gfp_mask);
+               shost->cmd_pool = NULL;
                return -ENOMEM;
        }
        list_add(&cmd->list, &shost->free_list);
@@ -481,6 +482,13 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
  */
 void scsi_destroy_command_freelist(struct Scsi_Host *shost)
 {
+       /*
+        * If cmd_pool is NULL the free list was not initialized, so
+        * do not attempt to release resources.
+        */
+       if (!shost->cmd_pool)
+               return;
+
        while (!list_empty(&shost->free_list)) {
                struct scsi_cmnd *cmd;