From patchwork Fri Mar 9 04:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10269737 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 67D246016D for ; Fri, 9 Mar 2018 05:45:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45CDD29C8F for ; Fri, 9 Mar 2018 05:45:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EC7129C9A; Fri, 9 Mar 2018 05:45:39 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 B52D929C92 for ; Fri, 9 Mar 2018 05:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750898AbeCIFph (ORCPT ); Fri, 9 Mar 2018 00:45:37 -0500 Received: from gateway30.websitewelcome.com ([192.185.149.4]:33771 "EHLO gateway30.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750753AbeCIFph (ORCPT ); Fri, 9 Mar 2018 00:45:37 -0500 X-Greylist: delayed 1500 seconds by postgrey-1.27 at vger.kernel.org; Fri, 09 Mar 2018 00:45:37 EST Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 4CAA21119A for ; Thu, 8 Mar 2018 22:58:15 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id uA6heC2ZHz8j4uA6heI8SJ; Thu, 08 Mar 2018 22:58:15 -0600 Received: from [189.175.117.58] (port=32796 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1euA6g-004IkL-IR; Thu, 08 Mar 2018 22:58:14 -0600 Date: Thu, 8 Mar 2018 22:58:13 -0600 From: "Gustavo A. R. Silva" To: Support Opensource , Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Kees Cook , "Gustavo A. R. Silva" Subject: [PATCH] power: supply: da9150-fg: remove VLA usage Message-ID: <20180309045813.GA11964@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.175.117.58 X-Source-L: No X-Exim-ID: 1euA6g-004IkL-IR X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.175.117.58]:32796 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 3 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation to enabling -Wvla, remove VLA usage and replace it with fixed-length arrays. It seems that the length of array 'buf' will not exceed DA9150_QIF_SHORT_SIZE bytes (2 bytes). But a fixed length of DA9150_QIF_BYTE_SIZE bytes (8 bytes) was chosen in case this change in the future. Fixed as part of the directive to remove all VLAs from the kernel: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Gustavo A. R. Silva --- drivers/power/supply/da9150-fg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/da9150-fg.c b/drivers/power/supply/da9150-fg.c index 8b8ce97..96893be 100644 --- a/drivers/power/supply/da9150-fg.c +++ b/drivers/power/supply/da9150-fg.c @@ -92,7 +92,7 @@ struct da9150_fg { static u32 da9150_fg_read_attr(struct da9150_fg *fg, u8 code, u8 size) { - u8 buf[size]; + u8 buf[DA9150_QIF_BYTE_SIZE]; u8 read_addr; u32 res = 0; int i; @@ -111,7 +111,7 @@ static void da9150_fg_write_attr(struct da9150_fg *fg, u8 code, u8 size, u32 val) { - u8 buf[size]; + u8 buf[DA9150_QIF_BYTE_SIZE]; u8 write_addr; int i;