mirror of
https://github.com/torvalds/linux.git
synced 2026-10-22 23:01:49 +02:00
ubi: use put_user() when filling the erase counter array
ubi_get_ec_info() checks the user's erase_counters array with access_ok() and then fills it one entry at a time with __put_user(), taking the wear-leveling lock for each entry in between. Each of those accesses enables and disables user access on its own, so the up-front check saves nothing. Use put_user(). The access_ok() stays, so a bad array still fails before anything is written. This is part of getting rid of __get_user() and __put_user() entirely. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d1280054f8
commit
e0d5fa9ae4
|
|
@ -861,7 +861,7 @@ static int ubi_get_ec_info(struct ubi_device *ubi, struct ubi_ecinfo_req __user
|
|||
int ec;
|
||||
|
||||
if (ubi_io_is_bad(ubi, peb)) {
|
||||
if (__put_user(UBI_UNKNOWN, ureq->erase_counters+read_cnt))
|
||||
if (put_user(UBI_UNKNOWN, ureq->erase_counters+read_cnt))
|
||||
return -EFAULT;
|
||||
|
||||
continue;
|
||||
|
|
@ -877,7 +877,7 @@ static int ubi_get_ec_info(struct ubi_device *ubi, struct ubi_ecinfo_req __user
|
|||
|
||||
spin_unlock(&ubi->wl_lock);
|
||||
|
||||
if (__put_user(ec, ureq->erase_counters+read_cnt))
|
||||
if (put_user(ec, ureq->erase_counters+read_cnt))
|
||||
return -EFAULT;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user