Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1098044pxm; Wed, 23 Feb 2022 18:05:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJycdTqw41B/INDB85CqGGdHzaHjNLDOd/J8OEXLxG8Lbjt0q+AEo0QqX52VQKwk90KIZ0Cz X-Received: by 2002:a63:c115:0:b0:373:1840:5cbf with SMTP id w21-20020a63c115000000b0037318405cbfmr546956pgf.382.1645668309065; Wed, 23 Feb 2022 18:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645668309; cv=none; d=google.com; s=arc-20160816; b=fB52U/L5wSDfZ6B07w+97MMT6neLt+gGpi6mWeyPqB72FPMd4JZinmRWf5ZX3d9DU4 e6GVKyz4D0co8ZvIxIHubSnwNodQmA5kjaZd5n22ptIQoIbg61RomVSwWxXFiWEHBA2o h0o5X3eQKvedOUif8ksoDXNpe6KcqBBrQqC00iiSPy1KjwKjT+tbB55pmOeL3wW8Gl7p GZZxTpitvLampWG4XbBIujrEI+SdrPF+btIc4hmuB5vdXXOxzq7D2CsdMVaORiTkHrM7 unsvUpuRPlYedDTirttkpr667WtR+Nxoi7oib5noVTaUGosQwCTenOmsVcMOWTAPlpQm bEfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=t8MPPK30DtlCQHux+g7xPcTxNihra4Q/dwbimkdpxrg=; b=QiFUK9SuSbtXynKuVl7h7+TsddeqSuAm8gly3/wQ1lzNEfJHcqQHQ4oguo1Q6tJYfT oWqkJOUHxJbkDQ64OvW3Q+zgqn8rUc2WPzZ8hGiAd7YZoGp7/rouz41p32PKfMApW7H7 KR8Fc98grJACTYmOnDAg6NBPuUC9h0GUu+1O3wICYlPH44aLvLV118WKBOpY6pmoSx5d Om6Jn9LzzaoNf3rePWNcvmKHarrsM5lRWZYOUEOjWfgRjrFvvkwKyiyliRjoBOtATG6t 6tOhTTlasOedln5oSLRvU5sNCGJmSm3PJYD8VkEp7QN6QOlNlXtZuD35ckw8/KEpiPfE uRMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=rUwKrA9i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m20si1106360pfk.319.2022.02.23.18.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 18:05:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=rUwKrA9i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8797015B9B4; Wed, 23 Feb 2022 17:32:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbiBXBcs (ORCPT + 99 others); Wed, 23 Feb 2022 20:32:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiBXBcr (ORCPT ); Wed, 23 Feb 2022 20:32:47 -0500 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A062B43395; Wed, 23 Feb 2022 17:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645666338; x=1677202338; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=t8MPPK30DtlCQHux+g7xPcTxNihra4Q/dwbimkdpxrg=; b=rUwKrA9ix9IdpjqmYQBuTpPDneIU7hqxFUn7vqzlvKramSrnBp0Oe12y 9FiJtftDsJx0mSS1eEMPDpY6cSuxeJz+0RdDok4L+V2fTyM5o5KCQ0Wsu O6YbD9N/32hsYqsYPIrrNViutbYjpOHNTFHEeuP1KdnSiMAdsaKGyj0du c=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 23 Feb 2022 16:48:05 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2022 16:48:05 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Wed, 23 Feb 2022 16:48:05 -0800 Received: from [10.48.243.226] (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Wed, 23 Feb 2022 16:48:04 -0800 Message-ID: <657eecf0-a5d5-a9c0-2954-dbc865f33a7f@quicinc.com> Date: Wed, 23 Feb 2022 16:48:04 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH 1/6][next] ath6kl: wmi: Replace one-element array with flexible-array member in struct wmi_begin_scan_cmd Content-Language: en-US To: "Gustavo A. R. Silva" , , CC: Kalle Valo , "David S. Miller" , Jakub Kicinski , , References: From: Jeff Johnson In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/22/2022 6:38 PM, Gustavo A. R. Silva wrote: > Replace one-element array with flexible-array member in struct > wmi_begin_scan_cmd. Also, make use of the struct_size() helper. > > This issue was found with the help of Coccinelle and audited and fixed, > manually. > > Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays > Link: https://github.com/KSPP/linux/issues/79 > Signed-off-by: Gustavo A. R. Silva > --- > drivers/net/wireless/ath/ath6kl/wmi.c | 9 ++------- > drivers/net/wireless/ath/ath6kl/wmi.h | 2 +- > 2 files changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c > index bd1ef6334997..e1c950014f3e 100644 > --- a/drivers/net/wireless/ath/ath6kl/wmi.c > +++ b/drivers/net/wireless/ath/ath6kl/wmi.c > @@ -2008,7 +2008,7 @@ int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx, > struct ieee80211_supported_band *sband; > struct sk_buff *skb; > struct wmi_begin_scan_cmd *sc; > - s8 size, *supp_rates; > + s8 *supp_rates; > int i, band, ret; > struct ath6kl *ar = wmi->parent_dev; > int num_rates; > @@ -2023,18 +2023,13 @@ int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx, > num_chan, ch_list); > } > > - size = sizeof(struct wmi_begin_scan_cmd); > - > if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) > return -EINVAL; > > if (num_chan > WMI_MAX_CHANNELS) > return -EINVAL; > > - if (num_chan) > - size += sizeof(u16) * (num_chan - 1); > - > - skb = ath6kl_wmi_get_new_buf(size); > + skb = ath6kl_wmi_get_new_buf(struct_size(sc, ch_list, num_chan)); > if (!skb) > return -ENOMEM; > > diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h > index 784940ba4c90..322539ed9c12 100644 > --- a/drivers/net/wireless/ath/ath6kl/wmi.h > +++ b/drivers/net/wireless/ath/ath6kl/wmi.h > @@ -863,7 +863,7 @@ struct wmi_begin_scan_cmd { > u8 num_ch; > > /* channels in Mhz */ > - __le16 ch_list[1]; > + __le16 ch_list[]; > } __packed; > > /* wmi_start_scan_cmd is to be deprecated. Use Reviewed-by: Jeff Johnson