Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=09ff92fea2890c697a36d8b26f5a3ea725ef8fb4
Commit:     09ff92fea2890c697a36d8b26f5a3ea725ef8fb4
Parent:     cab537d609fb718e9fb09d73e3e3e3062db25743
Author:     Alan Stern <[EMAIL PROTECTED]>
AuthorDate: Mon May 21 09:55:04 2007 -0400
Committer:  James Bottomley <[EMAIL PROTECTED]>
CommitDate: Tue May 22 14:08:24 2007 -0500

    [SCSI] sd: fix refcounting regression in suspend/resume routines
    
    This patch (as909) fixes a couple of refcounting errors in the sd
    driver's suspend and resume methods.
    
    Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
    Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
---
 drivers/scsi/sd.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 00e4666..3d8c9cb 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1789,7 +1789,7 @@ static void sd_shutdown(struct device *dev)
 static int sd_suspend(struct device *dev, pm_message_t mesg)
 {
        struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
-       int ret;
+       int ret = 0;
 
        if (!sdkp)
                return 0;       /* this can happen */
@@ -1798,30 +1798,34 @@ static int sd_suspend(struct device *dev, pm_message_t 
mesg)
                sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
                ret = sd_sync_cache(sdkp);
                if (ret)
-                       return ret;
+                       goto done;
        }
 
        if (mesg.event == PM_EVENT_SUSPEND &&
            sdkp->device->manage_start_stop) {
                sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
                ret = sd_start_stop_device(sdkp, 0);
-               if (ret)
-                       return ret;
        }
 
-       return 0;
+done:
+       scsi_disk_put(sdkp);
+       return ret;
 }
 
 static int sd_resume(struct device *dev)
 {
        struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
+       int ret = 0;
 
        if (!sdkp->device->manage_start_stop)
-               return 0;
+               goto done;
 
        sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
+       ret = sd_start_stop_device(sdkp, 1);
 
-       return sd_start_stop_device(sdkp, 1);
+done:
+       scsi_disk_put(sdkp);
+       return ret;
 }
 
 /**
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to