Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4626908pxj; Wed, 12 May 2021 09:32:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrJHn6N9uQAeU05yT9u31tROWVGdlK/MIEhboft5Jxf8qGpIjjHJUkg0i8NE9mw3voLal1 X-Received: by 2002:a17:906:2504:: with SMTP id i4mr38485453ejb.297.1620837127908; Wed, 12 May 2021 09:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837127; cv=none; d=google.com; s=arc-20160816; b=LzlPlpCluBxBqDD8FAMYZ8MnQ9hghcKJNbaLg2l0L8pQRkFdqbqXZwqnrfA0bDwl30 KMDbS/G1AKxh1ex7UbvpcuvGphJ1ciIZNWZxuLa2ZhTaRBGIABA0jChu9GKN2ABe2LQ+ ueeqoyw53ZHomW9Lhw1Mr3UHmmtVJ4UMniD9NrCNEpSvc2pVSIVB16VT8Egvz0soWmW7 /hM161Gi6sPMkWFipsQSBGLwT6xQCF5YiFGd7Kw2GKrw/n7lXNNIpx+lv7Q7fAXQNf4J NveljR7eBe6d2xVXLqwzsDSoYWfno8YrkU8V7+N4t8eW/57foUyq3XGK7+qnptHgUiWM 6cHQ== 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=hfahdytygsfePiiywbM2GikYs97uyw8+/wk96VTxs5A=; b=pFgzGPXh3ir/msbJPxV/MHa90GOD3l4lz21v5T9Q0/x8o1LJQvDctXxHAylo9s5QVQ KZJwpCOzCUTiUGJgWhxTwJb2FVtW3HmyVgYtG5HL5XMsnUNTNr9B9fbfsjth4R/d48Bi 0hKG60eNk1lDmHuH5t2uqgrzzuRG/gDG39QTsWT95Xv4KyqP6X+LSExep4q+7vzlyIRJ 7+v0NUUbxq2huPMQAFjNUfQPYAvjwU3BKV7sJJFI21TDLiMynlI73VHBTzgmJmFpJ4kA bAx6FIx22mrvz0y0qtJXc8MjT4CTEpTXjdsXheCukfELK3XM+CIhspP1KdiGZYckJ87n xnvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xOfsx8hM; 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 qk30si397301ejb.152.2021.05.12.09.31.42; Wed, 12 May 2021 09:32:07 -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=xOfsx8hM; 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 S240237AbhELQad (ORCPT + 99 others); Wed, 12 May 2021 12:30:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:56528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234197AbhELPjO (ORCPT ); Wed, 12 May 2021 11:39:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BE36761C67; Wed, 12 May 2021 15:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832842; bh=1Z206rr+ID4sR0PVskAJ2Dfihs0zrPdTKGcuV4niXbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xOfsx8hMqh3jH+N22szmaNi1vh9XALPkF9XzZCFnp9K7yBjE1glnl0uITZOtR1nNB bmawK5QabPLWjMCyUm7OJu23/+YdnHfQbm/lu9JGJ869gvhz9xycaoA8jRba/P9ejB yaOTtDmWOjE0nofDdmodR95+4lXDhNXcSgxpS1SY= 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 5.10 411/530] mt7601u: fix always true expression Date: Wed, 12 May 2021 16:48:41 +0200 Message-Id: <20210512144833.269680557@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 c868582c5d22..aa3b64902cf9 100644 --- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c +++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c @@ -99,7 +99,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