aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-05-21 09:55:04 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-22 15:08:24 -0400
commit09ff92fea2890c697a36d8b26f5a3ea725ef8fb4 (patch)
treeb7e2ba71e34fcf0344aa6a2f0537a3478d72e191 /drivers/scsi
parentcab537d609fb718e9fb09d73e3e3e3062db25743 (diff)
[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 <stern@rowland.harvard.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/sd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 00e46662296f..3d8c9cb24f91 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1789,7 +1789,7 @@ static void sd_shutdown(struct device *dev)
1789static int sd_suspend(struct device *dev, pm_message_t mesg) 1789static int sd_suspend(struct device *dev, pm_message_t mesg)
1790{ 1790{
1791 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1791 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
1792 int ret; 1792 int ret = 0;
1793 1793
1794 if (!sdkp) 1794 if (!sdkp)
1795 return 0; /* this can happen */ 1795 return 0; /* this can happen */
@@ -1798,30 +1798,34 @@ static int sd_suspend(struct device *dev, pm_message_t mesg)
1798 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); 1798 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
1799 ret = sd_sync_cache(sdkp); 1799 ret = sd_sync_cache(sdkp);
1800 if (ret) 1800 if (ret)
1801 return ret; 1801 goto done;
1802 } 1802 }
1803 1803
1804 if (mesg.event == PM_EVENT_SUSPEND && 1804 if (mesg.event == PM_EVENT_SUSPEND &&
1805 sdkp->device->manage_start_stop) { 1805 sdkp->device->manage_start_stop) {
1806 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); 1806 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
1807 ret = sd_start_stop_device(sdkp, 0); 1807 ret = sd_start_stop_device(sdkp, 0);
1808 if (ret)
1809 return ret;
1810 } 1808 }
1811 1809
1812 return 0; 1810done:
1811 scsi_disk_put(sdkp);
1812 return ret;
1813} 1813}
1814 1814
1815static int sd_resume(struct device *dev) 1815static int sd_resume(struct device *dev)
1816{ 1816{
1817 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 1817 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
1818 int ret = 0;
1818 1819
1819 if (!sdkp->device->manage_start_stop) 1820 if (!sdkp->device->manage_start_stop)
1820 return 0; 1821 goto done;
1821 1822
1822 sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); 1823 sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
1824 ret = sd_start_stop_device(sdkp, 1);
1823 1825
1824 return sd_start_stop_device(sdkp, 1); 1826done:
1827 scsi_disk_put(sdkp);
1828 return ret;
1825} 1829}
1826 1830
1827/** 1831/**