Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp3698475ooa; Mon, 13 Aug 2018 16:41:00 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyxcu2J0lIGleiOOSDp8OaTNhoCVhJzF0vDCbmF9qcNDZXm9H8cvq50rt0vxgPZH22Ro3tA X-Received: by 2002:a17:902:b785:: with SMTP id e5-v6mr18200738pls.339.1534203660538; Mon, 13 Aug 2018 16:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534203660; cv=none; d=google.com; s=arc-20160816; b=rm9CtlKhX+mkSnMwgTUX7bCGQy86DaHPcr8+HrNJ9KKjkuvLdhwfjVUFiiEpWwZcoI f4ia1xv8LQVJHhDU7VHTXu+TgXhZ+8HbuPPjernIuD7aL63fu33VeAo4qtKno5oSdPV8 v5gujIpw3YFHjpFRSduqmorYVAVV9CiNQWq+rZJkIdkJDgUhgWZQFyB/baDae1HIGIpf kuUjDRQJogy9/wmPGqCFX+wD8Bqe4HwauEEyr1gYmFoiABtODjgU8WjNi4AsRCevKaxP xwh/39QqC5zV813vlkRRdFwcUzqWsUNQ1Ts151XnDtSKeCcYugx/Qj+X6gzuFUqVKZbj Hc4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature :arc-authentication-results; bh=Y1yR7DwknJsyXWYESqMJYxBOHIZGCQgygFIYNNOEob0=; b=q4nPuEObrGXKKuQ3/hC5IRXeI5+vAD1ZmjhIio7GUkHJTmDIkkASmhXMCKSPq/ASNx j19pKlYFOynJXnwaEtHcyJ+hybdDzywLQwU4cypU8Fg+B4QoEjfP5PqyD0xN+1GP8jHp gbCgL3RwnTH8Mrm9x4EsVo6d1S/rd+ZG6XKDY8+m6i2xOztq5o/EKgZF59iNt67Tq1G6 a8XqcJJpZtPDLlJEgGAokXdQZpV0dGG8l3t9ob1AZQCgtCvJw/pY4fm3Vvahm27UVkkA Ma85iRhfAVR8aWnNKrPFAQ8hRh28lS5YdYPU0gpd8dBTCK8W8EZNuYKDFmkAKCk/CQn/ mepg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aO83XHL2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si16807817pgc.450.2018.08.13.16.40.45; Mon, 13 Aug 2018 16:41:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aO83XHL2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732557AbeHNCYF (ORCPT + 99 others); Mon, 13 Aug 2018 22:24:05 -0400 Received: from mail-qk0-f202.google.com ([209.85.220.202]:47755 "EHLO mail-qk0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729947AbeHNCYF (ORCPT ); Mon, 13 Aug 2018 22:24:05 -0400 Received: by mail-qk0-f202.google.com with SMTP id 99-v6so18777449qkr.14 for ; Mon, 13 Aug 2018 16:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Y1yR7DwknJsyXWYESqMJYxBOHIZGCQgygFIYNNOEob0=; b=aO83XHL21ioMh1HKPNTYmwboj6sdmE6Rzq4hDdfOw1mmBNPJr1qJtfROdsy5FR5HOU Uq06PSYls2Wz6bAqUHGFNnBRqBKfOnp2AWSqZ5kik1nhL+uLjiWJ5mQt+l4We7r97Uvr T7oxwAA2vbVkZtRBIr1829EQaqBgSJMRDE91tqsVZRVlijTh1uqBia2sVbz85klCIlQk 5ZCwFInpJiRuCEk6CY4qpearPYmcXQCsWkhSH0HX/DlLKjP7RbS76tD1J9q2QVYIQAZX DcXsYjaGGRVaCFouvJr4yxPQAIVhdF9mRTAmr5f7OD4H/uvQrZ8P4v0lL+5BRlRClT/I gEeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Y1yR7DwknJsyXWYESqMJYxBOHIZGCQgygFIYNNOEob0=; b=qB4L8w+05605+4ReeyNx5NHABjGRkFK4LvNOrNnNQxjGZ+CFS6+3vfjTU9aeMTfTTH LuYsbOBxDd36GcJ1gc1lhgI2e7cN5OnFKXY66VtmKpiyUDofvwmxx4841KMeFs8SVB8k H2IshB3U6VAstfBtMdMVauMnheXoSovxgl0fWpPgMC/Ux+f9vd4jZmx/g1HqpnVbieYx trecTJmsjsrAeon+DZgt0bGBubLKGkzOvZW6J4NWAZS+7XpSwBMpOaKrwW4FZaDTlXhP EPFs5gKc6nEGXSJXSUCtZcWsxLattRuDGn9xI06yodEwMY2QjAVir61jsldLY75SAKgw h4uw== X-Gm-Message-State: AOUpUlGF9HE+ntOBmSmFr3hk/1ON86GDBoKmAcADKlL34De928ekGK8P bYuqiK5fAYSr50DW3yPrwJHufRQ7 X-Received: by 2002:ac8:2ffd:: with SMTP id m58-v6mr10960382qta.39.1534203575987; Mon, 13 Aug 2018 16:39:35 -0700 (PDT) Date: Mon, 13 Aug 2018 16:38:37 -0700 In-Reply-To: <20180813233839.190855-1-rkir@google.com> Message-Id: <20180813233839.190855-6-rkir@google.com> Mime-Version: 1.0 References: <20180813233839.190855-1-rkir@google.com> X-Mailer: git-send-email 2.18.0.865.gffc8e1a3cd6-goog Subject: [PATCH 6/9] platform: goldfish: pipe: Fail compilation if structs are too large From: rkir@google.com To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, tkjos@google.com, Roman Kiryanov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Kiryanov 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 --- 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 #include #include +#include #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