From patchwork Sat May 9 12:06:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11538233 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92CAC139A for ; Sat, 9 May 2020 12:07:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84D4E24954 for ; Sat, 9 May 2020 12:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728531AbgEIMHu (ORCPT ); Sat, 9 May 2020 08:07:50 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:45837 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbgEIMHq (ORCPT ); Sat, 9 May 2020 08:07:46 -0400 Received: from localhost.localdomain ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MHWvH-1jKU520UVt-00DX52; Sat, 09 May 2020 14:07:13 +0200 From: Arnd Bergmann To: Kalle Valo Cc: Arnd Bergmann , "Gustavo A. R. Silva" , Michal Kazior , Kalle Valo , "David S. Miller" , Wen Gong , Erik Stromdahl , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/2] ath10k: fix gcc-10 zero-length-bounds warnings Date: Sat, 9 May 2020 14:06:32 +0200 Message-Id: <20200509120707.188595-1-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:md3rGtm9B4AL9nvSbhTd+KISJpmcfvjMjuz727nzZm2ZvFT08RI 4X3GNiglYQmcZcXlGiFzAfI8qklVyu72RVyCSXUtfldCvePSj61BDEZlHHReaflvqiznmoE 5HonKZMPDVDwN29blRt/Ip7sw3mul8n1tgqN9WkhOKVzXFNcOZT5DWfk95qwreYQPZT6ryz eD7aa3o1noCIrZFf+tmXg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:xnYyufblF38=:aqdJovHTUmVD7l7sJtYi6R O2VyTtN8cEC5i1EHJ/QrGJTzuZeDvWHv+4wBXmOdq+vCri1/O+O8ZHnHEU62SyfrF2VyfbL40 3urDiERgiSr77LhdpxdMwRpoS8l2vfp6FvbIf2nz4ag/rn55duaDINqQSGCsJlTA/CNQQP0jA l6hqytr7uwp+aJzEUwGvkOHrv83UTBoC/MSyc2w1eqkEFKPb0CpMoAFJgw60vU4nYI5YDse8p TENge1jYBX1cKNmDact8vq15wBMtannapu9oLNfH4+OmRHVMRyiN/hUDOEQJCQgqT0aeotHkO Csd33s0vb2GCnFTQRRfhulmPZikLXUglgEOJkvKdwVMgOXkbWnbjFTRbh98jb8XCzrHqAEo5c RtjW1gozK+Ex0mMRGBCPUX5OcpV/WjDP4LdlMpbDPHYPfw2zA0slct/rVbfh3q6Y2U45h7OFp T8+JCeAntbaV/B3DRDFUeW7EoheAdm4WGc+FOn1xP9r8QxDXlelhmOTDqJ6BqjIXxYl7NgZ/w 2KPZp/Ra90JLJeLJrbK4XkYJNA3JE/YPLKLOVSlaTPT8tnn5FSOVKoQ92RVzs1qTjfk5kGREu J05vfQLaHM3KrUEV79aUqy6k1iOi8ZPVrYEnyGH5EKHeNEkF0SfODkaDa6HhzDqKgQO/MN8d1 9S0A+9/C/kF+KJhNTCmScZYK6WS4xkZa9tKHHZ3MCSOXS9+FGw7oIgvrs4U+IufVz3qsAGECG JQiilaFIEJbIHBCoYPfe2Bq2WjwoZr+Uw83CMMw0aUvIJdeHeqv9MMZC07pzZyXotRlPTRJbz FEJswylkJbsUwPMFx0fF8aI6b2RjADap9Uy5S4eazZvyxlM9dE= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org gcc-10 started warning about out-of-bounds access for zero-length arrays: In file included from drivers/net/wireless/ath/ath10k/core.h:18, from drivers/net/wireless/ath/ath10k/htt_rx.c:8: drivers/net/wireless/ath/ath10k/htt_rx.c: In function 'ath10k_htt_rx_tx_fetch_ind': drivers/net/wireless/ath/ath10k/htt.h:1683:17: warning: array subscript 65535 is outside the bounds of an interior zero-length array 'struct htt_tx_fetch_record[0]' [-Wzero-length-bounds] 1683 | return (void *)&ind->records[le16_to_cpu(ind->num_records)]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/wireless/ath/ath10k/htt.h:1676:29: note: while referencing 'records' 1676 | struct htt_tx_fetch_record records[0]; | ^~~~~~~ Make records[] a flexible array member to allow this, moving it behind the other zero-length member that is not accessed in a way that gcc warns about. Fixes: 3ba225b506a2 ("treewide: Replace zero-length array with flexible-array member") Fixes: 22e6b3bc5d96 ("ath10k: add new htt definitions") Signed-off-by: Arnd Bergmann --- drivers/net/wireless/ath/ath10k/htt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h index 8f3710cf28f4..aa056a186402 100644 --- a/drivers/net/wireless/ath/ath10k/htt.h +++ b/drivers/net/wireless/ath/ath10k/htt.h @@ -1673,8 +1673,8 @@ struct htt_tx_fetch_ind { __le32 token; __le16 num_resp_ids; __le16 num_records; - struct htt_tx_fetch_record records[0]; __le32 resp_ids[0]; /* ath10k_htt_get_tx_fetch_ind_resp_ids() */ + struct htt_tx_fetch_record records[]; } __packed; static inline void * From patchwork Sat May 9 12:06:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11538231 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC938139A for ; Sat, 9 May 2020 12:07:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9955C21473 for ; Sat, 9 May 2020 12:07:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728365AbgEIMHm (ORCPT ); Sat, 9 May 2020 08:07:42 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:40871 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbgEIMHl (ORCPT ); Sat, 9 May 2020 08:07:41 -0400 Received: from localhost.localdomain ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1N7RDn-1j3u291OAv-017q80; Sat, 09 May 2020 14:07:28 +0200 From: Arnd Bergmann To: Kalle Valo Cc: Arnd Bergmann , Maharaja Kennadyrajan , "David S. Miller" , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/2] ath10k: fix ath10k_pci struct layout Date: Sat, 9 May 2020 14:06:33 +0200 Message-Id: <20200509120707.188595-2-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200509120707.188595-1-arnd@arndb.de> References: <20200509120707.188595-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:PwCZxgyuJPTotwKY546enVLNSjcEZwvUHNxW+ZeWlIbFQWRywio zufRY0iO7HkMQ8lpmHRn7fJ7AYqhTdmqsbL4v/355PdA91ANvQzywOGv32/DXJRqAzoINys YI1hF8rtOMGIYhcGlOLQvSRJB+NxU1YCGGTFGdB1h3UOqf1PfcOw8D2VVKjSHwdNXuWUWqx wS8L4ildOaTnVsG7hvJ4g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:pQykyiEsgvc=:5PhDczXHDy7IquzkJB7qTx /TzHKhDP4SwR+IAaOr6xcVgCWBKtTo4cZXwMyTyZSPvlnPeIDkbsJWDsJnhBuEHtt9e+HzHF4 eRR3/J1QXBWDNRKTUKdxDCOkvg4bbkDqABbaMM0agEkDoLrnGj/f3NepIcaKGW228mgtbtu8C s4Kc8sFNIu4AdyYrfEStC7jccU2QsSyq2lQDMhf1wJaKrYxtwaeyfYYgbFY9OaOxBKxcUGV1w EkrQgy+lkZrZY8WJ0kWCZDlGYIUJB9HrAhwxVyW6dO92OemvzlrOjRAu4ZImR8V69bCoWGJJ0 4I+wcFjVecW2davHhm4mN3QQmmCgx30e1gTSUlRTAu93V6+2vudc5QgwBUedYCI86kN+x9Beo r+okGwG/0QqR0UyHnC+xJ6NdK71oo4zSghPiHYtLOTPsRqNRCttYs6s7ZAndqMJfxG+uJa7uD NESEzJTIYhpBW+d9wbt+QRl9m0vXj8lrAHf9vExbOSGyl6br9wuyfoPpDWUhgz1zlAv7q+PcO /9cpPmMeDMYjKNnKDLmfAWPsUM2g5kG7B6Wl682HScUYZDjmwts9cTvjD6Wp/DiRJ2Z8plHaD Q7/+e5gfUd7VDBrSw4XQvm6tQFxxrkIAtoFCzZCJoyEcAZbfJ2Z5kByMuT37zVb7lzNg5EOnU rs2QXjHQh6HSbSnEYrSNaAAcWVYx8XStXWaz9gyzr5Rx4cJLEavX0SJPLK+nd/wCq95+XWAvi rUl2iiomWXVzH3yr75qsmE5QZjWp1mMkgUMPGBDDgJyh9wIi4oK/+WWnIbuMmLoUE+GSK722i +mzFCSq72AE9Nwq49GRlcizgTFDuZhr+DSP8QmUvBVXYM77A8Q= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org gcc-10 correctly points out a bug with a zero-length array in struct ath10k_pci: drivers/net/wireless/ath/ath10k/ahb.c: In function 'ath10k_ahb_remove': drivers/net/wireless/ath/ath10k/ahb.c:30:9: error: array subscript 0 is outside the bounds of an interior zero-length array 'struct ath10k_ahb[0]' [-Werror=zero-length-bounds] 30 | return &((struct ath10k_pci *)ar->drv_priv)->ahb[0]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/net/wireless/ath/ath10k/ahb.c:13: drivers/net/wireless/ath/ath10k/pci.h:185:20: note: while referencing 'ahb' 185 | struct ath10k_ahb ahb[0]; | ^~~ The last addition to the struct ignored the comments and added new members behind the array that must remain last. Change it to a flexible-array member and move it last again to make it work correctly, prevent the same thing from happening again (all compilers warn about flexible-array members in the middle of a struct) and get it to build without warnings. Fixes: 521fc37be3d8 ("ath10k: Avoid override CE5 configuration for QCA99X0 chipsets") Signed-off-by: Arnd Bergmann --- drivers/net/wireless/ath/ath10k/pci.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h index e3cbd259a2dc..862d0901c5b8 100644 --- a/drivers/net/wireless/ath/ath10k/pci.h +++ b/drivers/net/wireless/ath/ath10k/pci.h @@ -178,15 +178,16 @@ struct ath10k_pci { */ u32 (*targ_cpu_to_ce_addr)(struct ath10k *ar, u32 addr); + struct ce_attr *attr; + struct ce_pipe_config *pipe_config; + struct ce_service_to_pipe *serv_to_pipe; + /* Keep this entry in the last, memory for struct ath10k_ahb is * allocated (ahb support enabled case) in the continuation of * this struct. */ - struct ath10k_ahb ahb[0]; + struct ath10k_ahb ahb[]; - struct ce_attr *attr; - struct ce_pipe_config *pipe_config; - struct ce_service_to_pipe *serv_to_pipe; }; static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)