mtdchar: use kvmalloc() for potentially large allocations
authorMichał Kępień <kernel@kempniu.pl>
Mon, 16 May 2022 07:06:01 +0000 (09:06 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 9 Jun 2022 13:03:32 +0000 (15:03 +0200)
commit83208e106a8e8a859110ebb04a5e927ced911afb
tree1d04b1dc0c641071ca082577817e90def7b2a488
parenta1eda864c04cf24ea1130334963c6199318f6f95
mtdchar: use kvmalloc() for potentially large allocations

mtdchar_write_ioctl() calls kmalloc() with the 'size' argument set to
the smaller of two values: the write request's data/OOB length provided
by user space and the erase block size of the MTD device.  If the latter
is large, kmalloc() may not be able to serve such allocation requests.
Use kvmalloc() instead.  Correspondingly, replace kfree() calls with
kvfree() calls.

Suggested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220516070601.11428-3-kernel@kempniu.pl
drivers/mtd/mtdchar.c