Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp632468pxj; Thu, 20 May 2021 18:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWK2we5ZUCks+6LBKHAkbE+sJiis4Q1ZaxmB9TJogtgiWmj3HVLpSIHt48oWGt4MA+HB8n X-Received: by 2002:a02:3304:: with SMTP id c4mr529138jae.68.1621560537447; Thu, 20 May 2021 18:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621560537; cv=none; d=google.com; s=arc-20160816; b=Sd5RijZQNZ/WDUPwvdl59uLEiCi9TEOXEn0qOAGBb8mOZLHIBJIgOrh8D8no7zMI9d Q9TkgTbfHk4lY6bZIt1Qd7F4RVGsvCjUVwuoLoibyj4OAfsRAwCxfvUw5MODJgJbf40/ IrThe8L8awIAVHOQuFwEE7Oc+3RabPi9xNTgafsZzjzLRW8E7kGXLywidUmriLrMLIH5 GVQ5IgdHGzC8Y7eTjIfyITAI5CVA3ENx4yFrqZTquOSeUwszwuMZM34yYU0RLXDokrKv Fu4XwYle9ZZct/2lsDGDPCQpGD1cgNBqH7du4N9ImdULvrks840p2YJai3d03CZ9gJRA HdRA== 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=b+2QSZJqz5iOnwWPko57Ihed8SX2UFqzRnJ4s3seWZA=; b=tOduXU9SNubCW4ezSNx0W6rnZGeEiMTVXnBNdzlZtkxfiHI4TwwOokBgqOgT6ZzqzK DLWzurst0TXHRhUIKDkxDYAIYOEI4w1QlubNqjg9q9Fps4zpewZfB80cHdvE1HW6hV8s OiW7c9TprCt89vtKQRZHYluA1Ji8ra7g7lIA5+J/s2L01Qle1N4q3inzVqdINBOW6Nph lTC+aTkJN6ftKJldzQrJEDYa0CZub9S42p8d+yLh/D0ZHiyeDOFghMPK++5KWXsCn/Mr jVlmiRaYDx8zNUH/6KjQlP5Ibj0DSrzLu48sU35F2s6CSvzGUSSnOnX+bJgR/Zz7zIBC BRgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=obX0ARY9; 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 o12si4843755ilu.42.2021.05.20.18.28.42; Thu, 20 May 2021 18:28:57 -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=obX0ARY9; 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 S241414AbhETLiS (ORCPT + 99 others); Thu, 20 May 2021 07:38:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:39590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238841AbhETLSi (ORCPT ); Thu, 20 May 2021 07:18:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DE3561D63; Thu, 20 May 2021 10:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505402; bh=IdBLaM1TDE0U3XMX71HtZKmhPxkNI8dSG+PJ/3xBE0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=obX0ARY9fGW3P0QHuTSWUZMXHyj8Bhd9aKmstukO7YJroeZ4IVttUmIJQE78bh2l+ 2COl9Rca7UsnMDmlgcfw55MQ6SvYUvxGydtmVYsBY9NdXd1KzPFB9W5QCfs44v2PQS SPnYnna8gBW/7ikvJ/aL0XTmAbpwpxKavN+pTzWY= 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.4 119/190] mt7601u: fix always true expression Date: Thu, 20 May 2021 11:23:03 +0200 Message-Id: <20210520092106.141657658@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 8d8ee0344f7b..7b917c4613ad 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