Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kees Cook and committed by
Jens Axboe
4e178c17 7a6873be

+7 -3
+1 -1
drivers/block/Kconfig
··· 74 74 75 75 config CDROM 76 76 tristate 77 + select BLK_SCSI_REQUEST 77 78 78 79 config GDROM 79 80 tristate "SEGA Dreamcast GD-ROM drive" 80 81 depends on SH_DREAMCAST 81 82 select CDROM 82 - select BLK_SCSI_REQUEST # only for the generic cdrom code 83 83 help 84 84 A standard SEGA Dreamcast comes with a modified CD ROM drive called a 85 85 "GD-ROM" by SEGA to signify it is capable of reading special disks
+6 -2
drivers/cdrom/cdrom.c
··· 282 282 #include <linux/blkdev.h> 283 283 #include <linux/times.h> 284 284 #include <linux/uaccess.h> 285 + #include <scsi/scsi_common.h> 285 286 #include <scsi/scsi_request.h> 286 287 287 288 /* used to tell the module to turn on full debugging messages */ ··· 2223 2222 2224 2223 blk_execute_rq(q, cdi->disk, rq, 0); 2225 2224 if (scsi_req(rq)->result) { 2226 - struct request_sense *s = req->sense; 2225 + struct scsi_sense_hdr sshdr; 2226 + 2227 2227 ret = -EIO; 2228 - cdi->last_sense = s->sense_key; 2228 + scsi_normalize_sense(req->sense, req->sense_len, 2229 + &sshdr); 2230 + cdi->last_sense = sshdr.sense_key; 2229 2231 } 2230 2232 2231 2233 if (blk_rq_unmap_user(bio))