Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2215875yba; Mon, 6 May 2019 01:44:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzg2IrxKsfOOVvF/r64WC9i+T0+HuCBThsJI72VsPFeqaom2UdRd97zUaxsda6KhBMOnlps X-Received: by 2002:aa7:8186:: with SMTP id g6mr32343635pfi.126.1557132248128; Mon, 06 May 2019 01:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557132248; cv=none; d=google.com; s=arc-20160816; b=ipe5eNuiPUakTYSdDcuWWsGS6fNTqM3BrtZEt8UKZK9U4+5gBHav/zkVHtB2cj6QRO SPm6bEDKgMU+l7405Be9C6q/wWcC6GBEVaiF2kRMzgYPhilFafZAfo7sg7rCYlo6u7zt iFN4o4rYIE1ZahIE0AiwMCcdaYKtf/nlPgjzLP9cN8zdESaHw7yxGBhHzw474tWUB4KZ 1VlnDapqyrD7/ZpaFNCb29K2UardtQv6v0ArjmDuxvM57s/TA9z+4DT/DK6jQzny3Wv8 KmsSdBeA6P5tgf/eti7iLvBndeq39vnQlJ0sIadVEdG8eKfoQtl+4ItxQu5g4La0Z42w rMyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rQMvHYOaQNY2anKi/37kgJPaPZcCXO3Q6cY8uOyt0ow=; b=s9LkkecyauzUdm5BD6INb064nfIJjrG2wd6L65gVGteQb7l5Tq9ccgx49IQDyavE3Z Q5yStKxlef+/wkfz0rkBt4mBFUcAHT8AdbWvBkIRL3yxIhoBkOAZmigSRSbGc0KZE1X1 FRiwkT8w9nLOXvd8AkUQgNwRB/5mp0U5+WUerQfizsDFeeMkP5FkFR7k3s7efNOoLfD+ H7ZlDNs0KFcZInMZbWNek3c3vy7kQxUwmCMJcBXffvfIdeyTcXllX3eyFdBriFA38/CF Qup3ReNTp4E6MV4eAgIDr9TDnrs4shHqQ5C7cQW5WHkFnshSU+z6qfQUib6+Hk1CAK5A skPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si14512368ply.311.2019.05.06.01.43.53; Mon, 06 May 2019 01:44:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726085AbfEFIng (ORCPT + 99 others); Mon, 6 May 2019 04:43:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44416 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbfEFIng (ORCPT ); Mon, 6 May 2019 04:43:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 319603087931; Mon, 6 May 2019 08:43:36 +0000 (UTC) Received: from localhost (unknown [10.43.2.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCD2160A98; Mon, 6 May 2019 08:43:35 +0000 (UTC) Date: Mon, 6 May 2019 10:42:21 +0200 From: Stanislaw Gruszka To: linux-wireless@vger.kernel.org, Kalle Valo Cc: Yan-Hsuan Chuang Subject: Re: [PATCH 5.1] rtw88: fix subscript above array bounds compiler warning Message-ID: <20190506084221.GB2714@redhat.com> References: <20190506073917.10106-1-sgruszka@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190506073917.10106-1-sgruszka@redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 06 May 2019 08:43:36 +0000 (UTC) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is for 5.2 and v2 obviously. Stanislaw On Mon, May 06, 2019 at 09:39:17AM +0200, Stanislaw Gruszka wrote: > My compiler complains about: > > drivers/net/wireless/realtek/rtw88/phy.c: In function ???rtw_phy_rf_power_2_rssi???: > drivers/net/wireless/realtek/rtw88/phy.c:430:26: warning: array subscript is above array bounds [-Warray-bounds] > linear = db_invert_table[i][j]; > > According to comment power_db should be in range 1 ~ 96 . > To fix add check for boundaries before access the array. > > Signed-off-by: Stanislaw Gruszka > --- > RFC -> v1 > - add check before accessing the array insted of > rtw_phy_power_2_db() change. > v1 -> v2: > - return 1 for power_db < 1 > > drivers/net/wireless/realtek/rtw88/phy.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c > index 4381b360b5b5..9ca52a4d025a 100644 > --- a/drivers/net/wireless/realtek/rtw88/phy.c > +++ b/drivers/net/wireless/realtek/rtw88/phy.c > @@ -423,6 +423,11 @@ static u64 rtw_phy_db_2_linear(u8 power_db) > u8 i, j; > u64 linear; > > + if (power_db > 96) > + power_db = 96; > + else if (power_db < 1) > + return 1; > + > /* 1dB ~ 96dB */ > i = (power_db - 1) >> 3; > j = (power_db - 1) - (i << 3); > -- > 2.20.1 >