Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6535498ybv; Wed, 12 Feb 2020 14:20:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwrbLr/RfQP88asvkxRDMzvubBr++g9VSzd/b7t7xTvgwcZcxtMp8yPNHhd6TZ+qU3G9Zcu X-Received: by 2002:a05:6808:3b2:: with SMTP id n18mr894245oie.146.1581546015500; Wed, 12 Feb 2020 14:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581546015; cv=none; d=google.com; s=arc-20160816; b=lAUGElno12bqLip7rwzMgoi5ld0oBWn/Q/vGT3RTEfL67ZibqVVvJpbig06oxlxnYd fDdfKB/oaK6bN6LFG1eOxkgzjVXzLUVMBMBr3f305zZAdsTFpMoj8RVwZQkNX77ZzuH7 MLmKMLs9J1sdlR4brOoQ+OMEZSG8HiDWbqOHWou/1hMeVgEN/GIUcrWOPKtflH6s+ZQq SKOyrcPKEaeuB63hBEh4o50SC9rMDs0ykcnaA9OU/lzK+I3++WARq0lZoN35z/kOtTZc AfBp6kuj9pgSrfOgFZBhjIo4QQLdme0bYRx+2zOv+3qLIFB8Bv4IRox/pMy9HqOcvAuj enxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-version:dlp-reaction:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=wJbfWpnWETOJtnjFpjj4YuiY7Zbk1j6Muyns84HB4Fg=; b=ClrYGmrOTqfBiE6NpN1xucVnNk9RbgqLPVLTojbc1XHcxxjzGdKYvDZuNNmYmoy3Jl GiCtaMJVRarIx4fO3WVn3VKWXGtxAHYOKPB6qO4mIpmoA48o5t21ChPYTBs67Th8NjaX c5XsPj6kTl4mxVbxuEw7fJPre73cjUZM2L36CRai0RQUnwNr/RSoxJ/cmNKfYBaGZaL6 w74qyjNscvBZKs2Zcu1RJd+hj/q44EpSefDmq5SkenDkVygXtirYjJwoZk5xbZ4pVn+5 WIg42wo7Nc++x5Eb8/rG7Zqum1ihJDJtXm0XNRqyGv3P8Zn4+zbHNT9f9x+31QSJLGv1 X7jA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si222881oik.171.2020.02.12.14.20.02; Wed, 12 Feb 2020 14:20:15 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729162AbgBLWTx convert rfc822-to-8bit (ORCPT + 99 others); Wed, 12 Feb 2020 17:19:53 -0500 Received: from mga14.intel.com ([192.55.52.115]:28120 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728603AbgBLWTw (ORCPT ); Wed, 12 Feb 2020 17:19:52 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2020 14:19:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,434,1574150400"; d="scan'208";a="237849203" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga006.jf.intel.com with ESMTP; 12 Feb 2020 14:19:51 -0800 Received: from lcsmsx602.ger.corp.intel.com (10.109.210.11) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 12 Feb 2020 14:19:51 -0800 Received: from hasmsx602.ger.corp.intel.com (10.184.107.142) by LCSMSX602.ger.corp.intel.com (10.109.210.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 13 Feb 2020 00:19:49 +0200 Received: from hasmsx602.ger.corp.intel.com ([10.184.107.142]) by HASMSX602.ger.corp.intel.com ([10.184.107.142]) with mapi id 15.01.1713.004; Thu, 13 Feb 2020 00:19:48 +0200 From: "Winkler, Tomas" To: "Gustavo A. R. Silva" , Arnd Bergmann , Greg Kroah-Hartman CC: "linux-kernel@vger.kernel.org" , "Usyskin, Alexander" , "Lubart, Vitaly" Subject: RE: [PATCH] mei: bus: replace zero-length array with flexible-array member Thread-Topic: [PATCH] mei: bus: replace zero-length array with flexible-array member Thread-Index: AQHV4R8PZ6+DToj5cUCD4Y1TT5B8IKgYIqMQ Date: Wed, 12 Feb 2020 22:19:48 +0000 Message-ID: <71cd2c9eba7f4ac68de55148edb08e19@intel.com> References: <20200211210822.GA31368@embeddedor> In-Reply-To: <20200211210822.GA31368@embeddedor> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 x-originating-ip: [10.184.70.1] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Gustavo A. R. Silva > Sent: Tuesday, February 11, 2020 23:08 > To: Winkler, Tomas ; Arnd Bergmann > ; Greg Kroah-Hartman > Cc: linux-kernel@vger.kernel.org; Gustavo A. R. Silva > > Subject: [PATCH] mei: bus: replace zero-length array with flexible-array member > > The current codebase makes use of the zero-length array language extension to > the C90 standard, but the preferred mechanism to declare variable-length types > such as these ones is a flexible array member[1][2], introduced in C99: > > struct foo { > int stuff; > struct boo array[]; > }; > > By making use of the mechanism above, we will get a compiler warning in case > the flexible array does not occur last in the structure, which will help us prevent > some kind of undefined behavior bugs from being inadvertenly introduced[3] to > the codebase from now on. > > This issue was found with the help of Coccinelle. > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > [2] https://github.com/KSPP/linux/issues/21 > [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") > > Signed-off-by: Gustavo A. R. Silva Ack. > --- > drivers/misc/mei/bus-fixup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c index > 5fcac02233af..aa3648d59a8a 100644 > --- a/drivers/misc/mei/bus-fixup.c > +++ b/drivers/misc/mei/bus-fixup.c > @@ -107,7 +107,7 @@ struct mkhi_rule_id { struct mkhi_fwcaps { > struct mkhi_rule_id id; > u8 len; > - u8 data[0]; > + u8 data[]; > } __packed; > > struct mkhi_fw_ver_block { > @@ -135,7 +135,7 @@ struct mkhi_msg_hdr { > > struct mkhi_msg { > struct mkhi_msg_hdr hdr; > - u8 data[0]; > + u8 data[]; > } __packed; > > #define MKHI_OSVER_BUF_LEN (sizeof(struct mkhi_msg_hdr) + \ > -- > 2.25.0