diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-02-06 04:20:45 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-02-06 04:20:45 -0500 |
commit | 822bfa51ce44f2c63c300fdb76dc99c4d5a5ca9f (patch) | |
tree | c9eaa4357b5ebca49c47bd5a25beabaa992442aa /drivers/cdrom | |
parent | 9fa73472ddbcd3da87d35a7f4566eaaf345f798e (diff) |
cdrom: use copy_to_user() without the underscores
"nframes" comes from the user and "nframes * CD_FRAMESIZE_RAW" can wrap
on 32 bit systems. That would have been ok if we used the same wrapped
value for the copy, but we use a shifted value. We should just use the
checked version of copy_to_user() because it's not going to make a
difference to the speed.
Cc: stable@vger.kernel.com
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/cdrom')
-rw-r--r-- | drivers/cdrom/cdrom.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 55eaf474d32c..8fefe59f52a7 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -2119,11 +2119,6 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf, | |||
2119 | if (!nr) | 2119 | if (!nr) |
2120 | return -ENOMEM; | 2120 | return -ENOMEM; |
2121 | 2121 | ||
2122 | if (!access_ok(VERIFY_WRITE, ubuf, nframes * CD_FRAMESIZE_RAW)) { | ||
2123 | ret = -EFAULT; | ||
2124 | goto out; | ||
2125 | } | ||
2126 | |||
2127 | cgc.data_direction = CGC_DATA_READ; | 2122 | cgc.data_direction = CGC_DATA_READ; |
2128 | while (nframes > 0) { | 2123 | while (nframes > 0) { |
2129 | if (nr > nframes) | 2124 | if (nr > nframes) |
@@ -2132,7 +2127,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf, | |||
2132 | ret = cdrom_read_block(cdi, &cgc, lba, nr, 1, CD_FRAMESIZE_RAW); | 2127 | ret = cdrom_read_block(cdi, &cgc, lba, nr, 1, CD_FRAMESIZE_RAW); |
2133 | if (ret) | 2128 | if (ret) |
2134 | break; | 2129 | break; |
2135 | if (__copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr)) { | 2130 | if (copy_to_user(ubuf, cgc.buffer, CD_FRAMESIZE_RAW * nr)) { |
2136 | ret = -EFAULT; | 2131 | ret = -EFAULT; |
2137 | break; | 2132 | break; |
2138 | } | 2133 | } |
@@ -2140,7 +2135,6 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf, | |||
2140 | nframes -= nr; | 2135 | nframes -= nr; |
2141 | lba += nr; | 2136 | lba += nr; |
2142 | } | 2137 | } |
2143 | out: | ||
2144 | kfree(cgc.buffer); | 2138 | kfree(cgc.buffer); |
2145 | return ret; | 2139 | return ret; |
2146 | } | 2140 | } |