Skip to content

Commit 4e178c1

Browse files
keesaxboe
authored andcommitted
cdrom: Use struct scsi_sense_hdr internally
This removes more casts of struct request_sense and uses the standard struct scsi_sense_hdr instead. This also fixes any possible stale values since the prior code did not check the sense length. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 7a6873b commit 4e178c1

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎drivers/block/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ config AMIGA_Z2RAM
7474

7575
config CDROM
7676
tristate
77+
select BLK_SCSI_REQUEST
7778

7879
config GDROM
7980
tristate "SEGA Dreamcast GD-ROM drive"
8081
depends on SH_DREAMCAST
8182
select CDROM
82-
select BLK_SCSI_REQUEST # only for the generic cdrom code
8383
help
8484
A standard SEGA Dreamcast comes with a modified CD ROM drive called a
8585
"GD-ROM" by SEGA to signify it is capable of reading special disks

‎drivers/cdrom/cdrom.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
#include <linux/blkdev.h>
283283
#include <linux/times.h>
284284
#include <linux/uaccess.h>
285+
#include <scsi/scsi_common.h>
285286
#include <scsi/scsi_request.h>
286287

287288
/* used to tell the module to turn on full debugging messages */
@@ -2222,9 +2223,12 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
22222223

22232224
blk_execute_rq(q, cdi->disk, rq, 0);
22242225
if (scsi_req(rq)->result) {
2225-
struct request_sense *s = req->sense;
2226+
struct scsi_sense_hdr sshdr;
2227+
22262228
ret = -EIO;
2227-
cdi->last_sense = s->sense_key;
2229+
scsi_normalize_sense(req->sense, req->sense_len,
2230+
&sshdr);
2231+
cdi->last_sense = sshdr.sense_key;
22282232
}
22292233

22302234
if (blk_rq_unmap_user(bio))

0 commit comments

Comments
 (0)