Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp418892pxj; Thu, 20 May 2021 12:22:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDf/up1ymmkjXBhmMRwpc+HhQhAqxPDdyJCb0PTytQxHVM9ghCZ+qr5wC6GdsKqys9W19c X-Received: by 2002:a05:6402:15:: with SMTP id d21mr3347340edu.66.1621538548101; Thu, 20 May 2021 12:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538548; cv=none; d=google.com; s=arc-20160816; b=yPzEvfzYWIqeS0JAs8MWr/+EbW8weArGQndFlD1CmToJpEzPg3ERO8rcZrmGqS95wp DZzvzuj0gBN6AxFcmiEC/yezbKueC3i4iLn3kKU2NXBsTsP36+Rs+qR2LcwjGjI9/2Xu Qb6sIvSuW3gwgpEsyxVHYFJikPnKEP3AH5v86NxMYbNrkC0wM1fIfPUHwRIrTX2B5TE8 3kptfTvNGcpcIt1lvrBxGikxDJhL2gi78/qL/f7urH3v0bpt/JdBM+Gyqy66PvtF5tk6 hJWRtKrY4CpvN9FMGPvsRdtvPGmXgL+6uUNz3MjRXQXOe/B+Njkn176uq/A0QvdkvYQf SQug== 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=uasGZZOXMxhax0Qrb6zDjci2FjhkBCSDE0OAVkAE5MOKo+tjZeKWdCQ/TCflOcJh0B etIv2dpHrPW47e5az2jek5grdtPHUWfi7egSjkPfmA7ZFbf1mTSU76rhsZjO4/xP5Lv5 RQ5zweFw+96J7SSfq2ulWDdO9g0jzwABV7Iyl2zFsbEGfKPyE+WrI+q2aHh+1kev8ZJz 9Ymz06m+6HIOwqAlepbRs6HUQcRIuNIAnPKKvIur6PBy054PQSWPqWQSooCfF+nAo5fl PZOB06wfbmsUoPzkDcmxhV2xkqFDzzSWQ5sfBYajvFs7X8SmUP9A69CQVjGQkZZzTcWi PA0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r+bKRr2I; 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 w15si3445192ejb.550.2021.05.20.12.22.03; Thu, 20 May 2021 12:22:28 -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=r+bKRr2I; 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 S237752AbhETKvU (ORCPT + 99 others); Thu, 20 May 2021 06:51:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:39830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237814AbhETKfi (ORCPT ); Thu, 20 May 2021 06:35:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD9EB61C5F; Thu, 20 May 2021 09:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504431; bh=sEsfvlxfhDwNz/ByYf1XBGxL95q/Ch3vdnMjYnakl4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+bKRr2IKwANgWj1IsVOIzEXtlj5ks/xz3jbrLihwxyszhnKDFEl2NAGcftRu+YyQ hnMkYTAjxeRA4PUZK3L8mhJYNiaITzmTjfszV1D+bGLNOFU8MFGT67bCReQdKytvHP lVgCEZIzbNrn2IsrSBtMoMR9Lr6T8ieQz6nzvy34= 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.14 208/323] mt7601u: fix always true expression Date: Thu, 20 May 2021 11:21:40 +0200 Message-Id: <20210520092127.259353102@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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