linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver: floppy: fix warning in __alloc_pages
@ 2021-10-12  3:49 Dongliang Mu
  0 siblings, 0 replies; only message in thread
From: Dongliang Mu @ 2021-10-12  3:49 UTC (permalink / raw)
  To: Denis Efremov, Jens Axboe; +Cc: Dongliang Mu, linux-block, linux-kernel

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-12  3:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  3:49 [PATCH] driver: floppy: fix warning in __alloc_pages Dongliang Mu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).