block: fix error handling in sg_io
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 26 Aug 2014 14:14:02 +0000 (16:14 +0200)
committerJens Axboe <axboe@fb.com>
Tue, 26 Aug 2014 14:20:01 +0000 (08:20 -0600)
Before commit 2cada584b200 ("block: cleanup error handling in sg_io"),
we had ret = 0 before entering the last big if block of sg_io.

Since 2cada584b200, ret = -EFAULT, which breaks hdparm:

/dev/sda:
 setting Advanced Power Management level to 0xc8 (200)
 HDIO_DRIVE_CMD failed: Bad address
 APM_level      = 128

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Fixes: 2cada584b200 ("block: cleanup error handling in sg_io")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/scsi_ioctl.c

index 5dd477bfb4bccc7d58e7a6032af7aef9c6a1c390..9b8eaeca6a794b5be8e732567aceffbe6ab6ebdb 100644 (file)
@@ -330,6 +330,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
        if (blk_fill_sghdr_rq(q, rq, hdr, mode))
                goto out_free_cdb;
 
+       ret = 0;
        if (hdr->iovec_count) {
                size_t iov_data_len;
                struct iovec *iov = NULL;