Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09ff92fe authored by Alan Stern's avatar Alan Stern Committed by James Bottomley
Browse files

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent cab537d6
Loading
Loading
Loading
Loading
+11 −7
Original line number Original line Diff line number Diff line
@@ -1789,7 +1789,7 @@ static void sd_shutdown(struct device *dev)
static int sd_suspend(struct device *dev, pm_message_t mesg)
static int sd_suspend(struct device *dev, pm_message_t mesg)
{
{
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	int ret;
	int ret = 0;


	if (!sdkp)
	if (!sdkp)
		return 0;	/* this can happen */
		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");
		sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
		ret = sd_sync_cache(sdkp);
		ret = sd_sync_cache(sdkp);
		if (ret)
		if (ret)
			return ret;
			goto done;
	}
	}


	if (mesg.event == PM_EVENT_SUSPEND &&
	if (mesg.event == PM_EVENT_SUSPEND &&
	    sdkp->device->manage_start_stop) {
	    sdkp->device->manage_start_stop) {
		sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
		sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
		ret = sd_start_stop_device(sdkp, 0);
		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)
static int sd_resume(struct device *dev)
{
{
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
	int ret = 0;


	if (!sdkp->device->manage_start_stop)
	if (!sdkp->device->manage_start_stop)
		return 0;
		goto done;


	sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
	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;
}
}


/**
/**