Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp588107pxj; Thu, 20 May 2021 17:07:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuLjfkjCLUldzzhQis4UCCDaiqxNPPsq5trNvZwDWg7I0P/WgXOy0k64K7p8c58ZbC57p9 X-Received: by 2002:a05:6638:3445:: with SMTP id q5mr143479jav.120.1621555631690; Thu, 20 May 2021 17:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621555631; cv=none; d=google.com; s=arc-20160816; b=owVpPM3pSUa6nAOaZE2KhwatiTURg+AX8rYpOhLrkEWwVFnZWxc8aKX9Rk3vVSr0/K PeyVW6B2vkB9A+tHQJaMIQ+rkoIiArR14Itgnh4hvJaM9aPpHt2JXtIAiWUF+lNbSy6b DHj/BvYMR7E+agjkDSuUGGuvimm9v5YPr6dlHqQNAn1XJ2cB6DaJ+CpqYvEBV5KAvnwB p0ECidDY1xoGdZAGefQ/qs7wkqX1Vnz2hSoW5JXVASB95u43BvufSyVmVkR5t7RHBBTv TdNftkk7bvFjvUhwOTrpS82yUKlR21OUoe751NC/Pgd0Tqg3/TZKv5Vo4Dkdf8kiTQkw Cq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CK8mEA9E/ypgAz8DyOLM4funCwO2/DzciWgjxxgd+to=; b=J/skRxB+eLKRUh98YULI5OO1FB1OrCAxItDetdawkbSMreBYQkT4+9l4ePZua64RM3 PukrtWZXBqTcHnu1OGr7PHRdHjrhMPh6p/Ow4utD0cBDygZ7y75TJ4/yUKcvCk7D5U1Z Yr9Tt76h/7JyMvAE9pDGFcm4Fm8aKn0EsLt5OaUUl3r8tHyIKvy5nBKPR2JWbFAJIh0t Ipw0eiGbr3iB2ZeAP2XBdc/bXUENf//UBfxj/ERxCCAUZOb1eeVeqwa4WLVadG/uQVA3 Bvn+m0QwhVEqKISLCotGHAbu3G2uN2KNGiFovGDPt4EIpdEw40I3yQhvUCP/negWH+A+ NMTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lB86t4fz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m5si4367442jat.27.2021.05.20.17.06.57; Thu, 20 May 2021 17:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lB86t4fz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240583AbhETLVG (ORCPT + 99 others); Thu, 20 May 2021 07:21:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:57506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237769AbhETLAc (ORCPT ); Thu, 20 May 2021 07:00:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C68F61933; Thu, 20 May 2021 10:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505009; bh=sEsfvlxfhDwNz/ByYf1XBGxL95q/Ch3vdnMjYnakl4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lB86t4fzwrFPTr5BJGgKW37kvu6N3UJxXoUddWoNccAP+VN+wioqiRubGNJ9ftarF pLPKUdeKLyS+AeakL3iEwNTKQn39jkTOW51f1B/bTdfbV2/7zkrAduIbt7Da0CGStX Vj2iSqcHxGv98PphSK3zrz3MXi2nBAKqzAWUAe5Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Jakub Kicinski , Kalle Valo , Sasha Levin Subject: [PATCH 4.9 148/240] mt7601u: fix always true expression Date: Thu, 20 May 2021 11:22:20 +0200 Message-Id: <20210520092113.623232483@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 87fce88658ba047ae62e83497d3f3c5dc22fa6f9 ] Currently the expression ~nic_conf1 is always true because nic_conf1 is a u16 and according to 6.5.3.3 of the C standard the ~ operator promotes the u16 to an integer before flipping all the bits. Thus the top 16 bits of the integer result are all set so the expression is always true. If the intention was to flip all the bits of nic_conf1 then casting the integer result back to a u16 is a suitabel fix. Interestingly static analyzers seem to thing a bitwise ! should be used instead of ~ for this scenario, so I think the original intent of the expression may need some extra consideration. Addresses-Coverity: ("Logical vs. bitwise operator") Fixes: c869f77d6abb ("add mt7601u driver") Signed-off-by: Colin Ian King Acked-by: Jakub Kicinski Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20210225183241.1002129-1-colin.king@canonical.com Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt7601u/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.c b/drivers/net/wireless/mediatek/mt7601u/eeprom.c index da6faea092d6..80d0f64205f8 100644 --- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c +++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c @@ -106,7 +106,7 @@ mt7601u_has_tssi(struct mt7601u_dev *dev, u8 *eeprom) { u16 nic_conf1 = get_unaligned_le16(eeprom + MT_EE_NIC_CONF_1); - return ~nic_conf1 && (nic_conf1 & MT_EE_NIC_CONF_1_TX_ALC_EN); + return (u16)~nic_conf1 && (nic_conf1 & MT_EE_NIC_CONF_1_TX_ALC_EN); } static void -- 2.30.2