Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4630697pxj; Wed, 12 May 2021 09:37:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnXip3k0rYX0ka4PcP7oFZRWZmFq78uWb5alem6EXQ8kQcFX7AQhYMRDLbG5keN0UeSyjv X-Received: by 2002:a9d:1ea9:: with SMTP id n38mr32470396otn.233.1620837427965; Wed, 12 May 2021 09:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837427; cv=none; d=google.com; s=arc-20160816; b=qlqkZ2k446dcpc5knVx6Fy/6qOe0/HdRE4/Hp4fJWjaZcYY3KGtnIKQ2/Y/ENmIRZP 1eO6Hi8lrtI0OE3vIVPcH1CqEbVlgobvSx4nBda/qLgetvTlQ5sFcjNDgudIUEPwo2nn BemkLQ42Ij4Rs2/6iO0yjOL29E/pwyBeZm60F7jwmn9gIPQpdQHKKpWXVprm7TTtmgra qqJqrfLhC94Xw0wgKMd4H3BZuh+RRCHswfSVTh5CqViyVuHXAXBa592aWdJGFId1PxNn qZE9hXfvBFvD8XZ7MYs33uibEdQ4m7fk0usqhhg5vEfO7jbM8jc0AzxB+WRn3T6/9oES Jcow== 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=n0BFMkfL0UcQO/3tAU2yNy6uJ4AlCntOBqnbxBWxmvM=; b=Tcf+N5E+JR4EPKuQkHPL20/xQmiKqjbCy5sz51cEJvt/3bsHloolMYSFWyIdePLBca TD0HHDVdV+o/0kkBXaXKzmmlwbxGa5YSb1Q72BnvH5cmgXI4Dt9NCKqmUIqNomCI3c9X oePZO8zqIqjvHRlDBL1+bkETvmZ13mr+jBbYeUBhB7RxrcwSM6XDLZkG2wqMb3oGtpp0 p96ZclzSIu811D6MH4BdddyWpCGETZKddsgZyizfqZDtttqeFm2zVUUQ3RC/0fH5Fd9t iRv3jjkF+QMn8a2z4MAaa3sxP1kCpEZ3k86KsyY4nBZ5eeW+j72tGV3bi/LDpmbE8DTo p8aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UkLxBnmC; 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 m8si422497otk.137.2021.05.12.09.36.53; Wed, 12 May 2021 09:37: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=UkLxBnmC; 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 S243016AbhELQg2 (ORCPT + 99 others); Wed, 12 May 2021 12:36:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:40100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234479AbhELPo0 (ORCPT ); Wed, 12 May 2021 11:44:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B9E1961C90; Wed, 12 May 2021 15:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832964; bh=rcF/R4G0LhkYDowJkpAtYGrUbfTnqMqxMMPVihI0vFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UkLxBnmCdicEBKe6nIoh6Q79UcwRMSlc6bKFKX6P9pBSRsgKgazDEl6zEJnE8Q7Y6 1uNPh3A9GF9vmyZ7V4hCcQdzsZlQOMQRvAPr3YuJL5FGAYB4zKAYFzIPJLBc8qz4rA JkPa1nffhw3ddgGcja+TTWbLlz/Gh27UW8oirFqU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 495/530] bnxt_en: fix ternary sign extension bug in bnxt_show_temp() Date: Wed, 12 May 2021 16:50:05 +0200 Message-Id: <20210512144836.031185588@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: Dan Carpenter [ Upstream commit 27537929f30d3136a71ef29db56127a33c92dad7 ] The problem is that bnxt_show_temp() returns long but "rc" is an int and "len" is a u32. With ternary operations the type promotion is quite tricky. The negative "rc" is first promoted to u32 and then to long so it ends up being a high positive value instead of a a negative as we intended. Fix this by removing the ternary. Fixes: d69753fa1ecb ("bnxt_en: return proper error codes in bnxt_show_temp") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index a59c1f1fb31e..512457e0301d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9546,7 +9546,9 @@ static ssize_t bnxt_show_temp(struct device *dev, if (!rc) len = sprintf(buf, "%u\n", resp->temp * 1000); /* display millidegree */ mutex_unlock(&bp->hwrm_cmd_lock); - return rc ?: len; + if (rc) + return rc; + return len; } static SENSOR_DEVICE_ATTR(temp1_input, 0444, bnxt_show_temp, NULL, 0); -- 2.30.2