From: rkir@google.com
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, tkjos@google.com,
Roman Kiryanov <rkir@google.com>
Subject: [PATCH 6/9] platform: goldfish: pipe: Fail compilation if structs are too large
Date: Mon, 13 Aug 2018 16:38:37 -0700 [thread overview]
Message-ID: <20180813233839.190855-6-rkir@google.com> (raw)
In-Reply-To: <20180813233839.190855-1-rkir@google.com>
From: Roman Kiryanov <rkir@google.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@google.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
next prev parent reply other threads:[~2018-08-13 23:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 23:38 [PATCH 1/9] platform: goldfish: pipe: Fix comments to fit 80 columns rkir
2018-08-13 23:38 ` [PATCH 2/9] platform: goldfish: pipe: Update license rkir
2018-08-13 23:38 ` [PATCH 3/9] platform: goldfish: pipe: Fix checkpatch warning rkir
2018-08-13 23:38 ` [PATCH 4/9] platform: goldfish: pipe: Separate the host interface to a separate header rkir
2018-08-13 23:38 ` [PATCH 5/9] platform: goldfish: pipe: Update the comment for GFP_ATOMIC rkir
2018-08-13 23:38 ` rkir [this message]
2018-08-14 1:48 ` [PATCH 6/9] platform: goldfish: pipe: Fail compilation if structs are too large Joe Perches
2018-08-14 3:47 ` Roman Kiryanov
2018-08-14 4:41 ` Joe Perches
2018-08-13 23:38 ` [PATCH 7/9] platform: goldfish: pipe: Replace an array of 1 with a variable rkir
2018-08-13 23:38 ` [PATCH 8/9] platform: goldfish: pipe: Replace pr_ with dev_ for logging rkir
2018-08-14 1:30 ` Joe Perches
2018-08-14 3:16 ` kbuild test robot
2018-08-14 1:35 ` [PATCH 1/9] platform: goldfish: pipe: Fix comments to fit 80 columns Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180813233839.190855-6-rkir@google.com \
--to=rkir@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tkjos@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).