Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp347794pxj; Thu, 20 May 2021 10:40:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAoXGmya3Yso3986RHmw0iDCYmGY+iwb++dIMBTCJmiD5hst0gEdB/Ge8H5QQmGiP/U36q X-Received: by 2002:a05:6402:524b:: with SMTP id t11mr3321458edd.139.1621532431014; Thu, 20 May 2021 10:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532431; cv=none; d=google.com; s=arc-20160816; b=Uw8n0d0N9cHUHKGDmqpX9jmlyxPkvXDwIEEPRN96vWjmBXEl2YlNlzQU+ECLNInGzX GPjeCpA2fcnbl52ACDrVFmXoUfdDwa95tospWXcQiH9Bmz8U+avpCxVjzWXZMbhb1cVv F6TGS35mq0KvOPKrQRbMDlUAeZbHNiyNp4gdBcqVdf7iojJPJFPsDuufDycQbLBaxvdz 7QSNkHkBy4aGa51Zuq7KsCWXWA3oxFsm7m0UjNRv2CZ0z5HqpBO8DpCka+v4EpimtS1K bqI/x2rjlcLNb0s1nA9nj/xLWUEszIzptmpWOjJii+VMPlLZ6IhB6gBM3VkWHEAlEC47 pX4A== 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=EAmzEDMgYbLkzwJbP62RBrTsju7/M34xI0Fxw4Z4fq4=; b=HKJb8igZBf2/meJySnOZyIZ3a2VXi16IviEIl3xuAw/3xZBT8D0rTVQxhGZFD7yxzM 2EFW3/3tAtqXt2c+Eg7ZcrvH+QckMMOE0jGtUJ0e8ySX2nyCL04mJT/LrmfAyNQzdV+M r0IJpGTPN2I2Xu/E1EWVy3i0fZ9VHEBgEK2GAlLooa1BCvhGU+Hjdoec3vCj30SA9osm +GozY6zjvR0O5pHvPVgQUNO6Pj/yPPqMTPhLNrxuj3AKF8jZplM7S2LYZf4OA7dSuz7V wU0Tji3UH50sRwEiTEk/vin0PG45Xf69PdA+VBbnmSVHAAhQS3QLG7XkL8AKqI85f+5t DoQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LTyZc+uQ; 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 m1si3880933ejj.42.2021.05.20.10.40.07; Thu, 20 May 2021 10:40:31 -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=LTyZc+uQ; 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 S235062AbhETKHu (ORCPT + 99 others); Thu, 20 May 2021 06:07:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:37280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235065AbhETKB4 (ORCPT ); Thu, 20 May 2021 06:01:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5523B61919; Thu, 20 May 2021 09:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503581; bh=NMND5a38PnJybIJdhXNWIZnm42fz3uJk8mx8+O0DYK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LTyZc+uQYqLvKGlg1PMY2LHlt1csOW3B/Jw+gBulQzN9KYqxG5r85e6R40pq7EKxX AnjGnUZG0lDCLB2VYv4M9tHR5RMkRPD3f8FLmsEfmJRSkVc0k39E55dFqLKFPnWkHU nJtaX0/4H0cu/VLLi2/Jucqq4tE5mgtU3HQFqyEM= 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 4.19 285/425] bnxt_en: fix ternary sign extension bug in bnxt_show_temp() Date: Thu, 20 May 2021 11:20:54 +0200 Message-Id: <20210520092140.812412584@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 44ed2f6e2d96..6033970fb667 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6851,7 +6851,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