From: Damien Le Moal Date: Mon, 8 May 2017 05:59:02 +0000 (+0900) Subject: scsi: sd: Unlock zone in case of error in sd_setup_write_same_cmnd() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=29f6ca6916e29fc46f1418885374d9ed50430687;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git scsi: sd: Unlock zone in case of error in sd_setup_write_same_cmnd() scsi_io_init() may fail, leaving a zone of a zoned block device locked. Fix this by properly unlocking the write same request target zone if scsi_io_init() fails. Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f9d1432d7cc5..e60a309b26bf 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -948,6 +948,10 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) rq->__data_len = sdp->sector_size; ret = scsi_init_io(cmd); rq->__data_len = nr_bytes; + + if (sd_is_zoned(sdkp) && ret != BLKPREP_OK) + sd_zbc_write_unlock_zone(cmd); + return ret; }