[PATCH] driver: floppy: fix warning in __alloc_pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the user-provided length (ptr->length) is longer than one threshold,
it will trigger a warning in __alloc_pages.

Fix this by checking get_order(ptr->length) >= MAX_ORDER.

Signed-off-by: Dongliang Mu <mudongliangabcd@xxxxxxxxx>
---
 drivers/block/floppy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index fef79ea52e3e..8b88960e2784 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3109,6 +3109,8 @@ static int raw_cmd_copyin(int cmd, void __user *param,
 	if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
 		if (ptr->length <= 0)
 			return -EINVAL;
+		if (get_order(ptr->length) >= MAX_ORDER)
+			return -EINVAL;
 		ptr->kernel_data = (char *)fd_dma_mem_alloc(ptr->length);
 		fallback_on_nodma_alloc(&ptr->kernel_data, ptr->length);
 		if (!ptr->kernel_data)
-- 
2.25.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux