
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IC9E41 -------------------------------- This reverts commit 2a7cfb3955e30cec30df7f71a131e1dd95047764. Fix adaptation error in sg_release() during patch merge, revert this patch and re-merge the community fix in the next patch. Fixes: 2a7cfb3955e3 ("scsi: sg: Enable runtime power management") Signed-off-by: Zheng Qixing <zhengqixing@huawei.com> --- drivers/scsi/sg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 371b097881c0..59de84387def 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -307,6 +307,10 @@ sg_open(struct inode *inode, struct file *filp) if (retval) goto sg_put; + retval = scsi_autopm_get_device(device); + if (retval) + goto sdp_put; + /* scsi_block_when_processing_errors() may block so bypass * check if O_NONBLOCK. Permits SCSI commands to be issued * during error recovery. Tread carefully. */ @@ -314,7 +318,7 @@ sg_open(struct inode *inode, struct file *filp) scsi_block_when_processing_errors(device))) { retval = -ENXIO; /* we are in error recovery for this device */ - goto sdp_put; + goto error_out; } mutex_lock(&sdp->open_rel_lock); @@ -367,6 +371,8 @@ sg_open(struct inode *inode, struct file *filp) } error_mutex_locked: mutex_unlock(&sdp->open_rel_lock); +error_out: + scsi_autopm_put_device(device); sdp_put: kref_put(&sdp->d_ref, sg_device_destroy); scsi_device_put(device); @@ -386,7 +392,7 @@ sg_release(struct inode *inode, struct file *filp) SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp, "sg_release\n")); mutex_lock(&sdp->open_rel_lock); - kref_put(&sfp->f_ref, sg_remove_sfp); + scsi_autopm_put_device(sdp->device); sdp->open_cnt--; /* possibly many open()s waiting on exlude clearing, start many; -- 2.39.2