Patch "bnxt_en: fix ternary sign extension bug in bnxt_show_temp()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bnxt_en: fix ternary sign extension bug in bnxt_show_temp()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bnxt_en-fix-ternary-sign-extension-bug-in-bnxt_show_.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f0e2125a8b9ce38c81b8cd41e61b00c2458341d8
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Thu Apr 22 12:10:28 2021 +0300

    bnxt_en: fix ternary sign extension bug in bnxt_show_temp()
    
    [ 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 <dan.carpenter@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

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);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux