Skip to contentSkip to conversation

sd: Free the page in case of unknown provisioning_mode in scsi_setup_discard_cmnd.

PATCH Superseded Tao Ma 2 participants 2 messages Mar 22, 2011 SCSI

lore
Share & tools
lore

Tao Ma

author
#0 lore raw

PATCH 1/1 sd: Free the page in case of unknown provisioning_mode in scsi_setup_discard_cmnd.

From: Tao Ma <[email protected]>

This patch is inspired by a build waring.
drivers/scsi/sd.c:544: warning: ‘ret’ may be used uninitialized in this function

So we need to set a default value to ret here.
But a deep look at scsi_setup_discard_cmnd makes me think of which value should be set. Now we have BLKPREP_KILL and BLKPREP_DEFER to indicate an error. As in case of an unknown sdkp->provisioning_mode, we goto out directly. So I guess we should return BLKPREP_KILL here and free the page.

---
 drivers/scsi/sd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/sd.c +1 -1
index 3be5db5..91564bd 100644
@@ -541,7 +541,7 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
 	sector_t sector = bio->bi_sector;
 	unsigned int nr_sectors = bio_sectors(bio);
 	unsigned int len;
-	int ret;
+	int ret = BLKPREP_KILL;
 	char *buf;
 	struct page *page;
 
Signature · 1 line
1.6.3.GIT
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Tao Ma

From: Tao Ma <[email protected]>

This patch is inspired by a build waring.
drivers/scsi/sd.c:544: warning: ‘ret’ may be used uninitialized in this function

So we need to set a default value to ret here.
But a deep look at scsi_setup_discard_cmnd makes me think of which value should be set. Now we have BLKPREP_KILL and BLKPREP_DEFER to indicate an error. As in case of an unknown sdkp->provisioning_mode, we goto out directly. So I guess we should return BLKPREP_KILL here and free the page.

Yeah, there's no point in deferring it.