[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180813233839.190855-6-rkir@google.com>
Date: Mon, 13 Aug 2018 16:38:37 -0700
From: rkir@...gle.com
To: gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org, tkjos@...gle.com,
Roman Kiryanov <rkir@...gle.com>
Subject: [PATCH 6/9] platform: goldfish: pipe: Fail compilation if structs are
too large
From: Roman Kiryanov <rkir@...gle.com>
Since the driver provides no workaround prevent in cases if structs do
no fit into a memory page, it is better to fail complation to find about
the issue earlt instead of returning errors at runtime.
Signed-off-by: Roman Kiryanov <rkir@...gle.com>
---
drivers/platform/goldfish/goldfish_pipe.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index a4db4d12b09c..5eed4c824a53 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -63,6 +63,7 @@
#include <linux/dma-mapping.h>
#include <linux/mm.h>
#include <linux/acpi.h>
+#include <linux/bug.h>
#include "goldfish_pipe_qemu.h"
/*
@@ -797,9 +798,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
* needs to be contained in a single physical page. The easiest choice
* is to just allocate a page and place the buffers in it.
*/
- if (WARN_ON(sizeof(*dev->buffers) > PAGE_SIZE))
- return -ENOMEM;
-
+ BUILD_BUG_ON(sizeof(*dev->buffers) > PAGE_SIZE);
page = (char *)__get_free_page(GFP_KERNEL);
if (!page) {
kfree(dev->pipes);
@@ -842,8 +841,7 @@ static int goldfish_pipe_probe(struct platform_device *pdev)
struct resource *r;
struct goldfish_pipe_dev *dev = pipe_dev;
- if (WARN_ON(sizeof(struct goldfish_pipe_command) > PAGE_SIZE))
- return -ENOMEM;
+ BUILD_BUG_ON(sizeof(struct goldfish_pipe_command) > PAGE_SIZE);
/* not thread safe, but this should not happen */
WARN_ON(dev->base != NULL);
--
2.18.0.865.gffc8e1a3cd6-goog
Powered by blists - more mailing lists