From patchwork Thu Mar 8 18:45:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10268659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 356C8602C8 for ; Thu, 8 Mar 2018 18:45:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 232D527FAE for ; Thu, 8 Mar 2018 18:45:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 148712996A; Thu, 8 Mar 2018 18:45:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90EE227FAE for ; Thu, 8 Mar 2018 18:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752052AbeCHSpy (ORCPT ); Thu, 8 Mar 2018 13:45:54 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:45846 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751859AbeCHSpy (ORCPT ); Thu, 8 Mar 2018 13:45:54 -0500 Received: by mail-pg0-f65.google.com with SMTP id i133so2553095pgc.12; Thu, 08 Mar 2018 10:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2YFwmohdR8QeGrmxG+3+bGUj82+JMt+FGy0Be5ZAlgc=; b=Obn4MRFwAdjJrq0KRghzab4H4oj4E7b/j3E9v1K7lxNE7s1TKGgiqT+NZP5Z7R4rzT LQcOqen+SoeZpZJ7OKBIVT+2AY8mq3NKH3ZdYh65dIIlDxXomROFOgJVAi19jPZXQM/R 4N1k2PAdqMzL4/WhmzzONQhZWNOkJezfUO2Zz6zT7mLtsm9Yc5Tz9p4TNkoPf8+YV4e4 ZDRFWNfIUIh/cix9aBTxswxc3s5FT+3ZagXOatTJpl4vBZQE5CeIPUypjv6Z7hpfrw1G 6jeICEfUsPyAD6rwY/gYWDcpHbsxw55veYCl29VzD3/k04JNmg/Aky3XmrJMBiHfKOiq Rb0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2YFwmohdR8QeGrmxG+3+bGUj82+JMt+FGy0Be5ZAlgc=; b=pnRg0lnZbqpuJKyr1BPUy8tyPSocySuHt/ht6+ViXPYXchnYDu/a8TLIgodQlQ+t5F DhclLzQHcdRBHCt6owmVyNXAuPMskVG1YtySATJ9XtFvNfiEg0KxY/0lxclXdUXjRUD9 yeM2f2gRlX92KZmA+69svG8S5KZQ8OQyIsLfj1zMEL8n0omU8dgRnQFX++jWKx67YN6f naQp8xOJnf4qwHeOR+obglJjzH93ZOZrmksTxmlmoIXs6FVCO73P4zyyxZCNzIzllTt5 CI2msX22iP4tfI9TY5u/qsZoMDEtWPbVjMuEXosfeSF/GYukPessY+itpUxW0PBE0WFq Orvg== X-Gm-Message-State: APf1xPC3BrdqVVouYt4p3rwkuxm4IJ/5fufFWiH5At/WJXGTIhauH8He CV6pbE9CIWTP8SOOxxgbgT8= X-Google-Smtp-Source: AG47ELvfKeuw95dRJVVs/ZZebLDDnV0Ab+lmJLnu95HTYMsUQhBU+BOvOdN8ToeFTTRGb7adDRu2cw== X-Received: by 10.98.69.76 with SMTP id s73mr27577935pfa.31.1520534753361; Thu, 08 Mar 2018 10:45:53 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id w129sm44689249pfd.155.2018.03.08.10.45.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Mar 2018 10:45:52 -0800 (PST) From: Himanshu Jha To: jic23@kernel.org Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, garsilva@embeddedor.com, keescook@chromium.org, Himanshu Jha Subject: [PATCH] iio: potentiometer: ds1803: Remove VLA usage Date: Fri, 9 Mar 2018 00:15:33 +0530 Message-Id: <1520534733-1743-1-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation to enabling -Wvla, remove VLA usage and replace it with fixed a fixed length array and therefore, prevent potential stack overflow attacks. Fixed as a part of the discussion to remove all VLAs from the kernel: https://lkml.org/lkml/2018/3/7/621 Cc: keescook@chromium.org Signed-off-by: Himanshu Jha --- drivers/iio/potentiometer/ds1803.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c index 9b0ff4a..6bf12c9 100644 --- a/drivers/iio/potentiometer/ds1803.c +++ b/drivers/iio/potentiometer/ds1803.c @@ -64,7 +64,7 @@ static int ds1803_read_raw(struct iio_dev *indio_dev, struct ds1803_data *data = iio_priv(indio_dev); int pot = chan->channel; int ret; - u8 result[indio_dev->num_channels]; + u8 result[ARRAY_SIZE(ds1803_channels)]; switch (mask) { case IIO_CHAN_INFO_RAW: