Patch "firmware: arm_scpi: Prevent the ternary sign expansion bug" has been added to the 4.19-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

    firmware: arm_scpi: Prevent the ternary sign expansion bug

to the 4.19-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:
     firmware-arm_scpi-prevent-the-ternary-sign-expansion.patch
and it can be found in the queue-4.19 subdirectory.

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



commit f07f1b7b976e984a75a812e29686b1d855156c2b
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Thu Apr 22 12:02:29 2021 +0300

    firmware: arm_scpi: Prevent the ternary sign expansion bug
    
    [ Upstream commit d9cd78edb2e6b7e26747c0ec312be31e7ef196fe ]
    
    How the type promotion works in ternary expressions is a bit tricky.
    The problem is that scpi_clk_get_val() returns longs, "ret" is a int
    which holds a negative error code, and le32_to_cpu() is an unsigned int.
    We want the negative error code to be cast to a negative long.  But
    because le32_to_cpu() is an u32 then "ret" is type promoted to u32 and
    becomes a high positive and then it is promoted to long and it is still
    a high positive value.
    
    Fix this by getting rid of the ternary.
    
    Link: https://lore.kernel.org/r/YIE7pdqV/h10tEAK@mwanda
    Fixes: 8cb7cf56c9fe ("firmware: add support for ARM System Control and Power Interface(SCPI) protocol")
    Reviewed-by: Cristian Marussi <cristian.marussi@xxxxxxx>
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    [sudeep.holla: changed to return 0 as clock rate on error]
    Signed-off-by: Sudeep Holla <sudeep.holla@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index c7d06a36b23a..baa7280eccb3 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -563,8 +563,10 @@ static unsigned long scpi_clk_get_val(u16 clk_id)
 
 	ret = scpi_send_message(CMD_GET_CLOCK_VALUE, &le_clk_id,
 				sizeof(le_clk_id), &rate, sizeof(rate));
+	if (ret)
+		return 0;
 
-	return ret ? ret : le32_to_cpu(rate);
+	return le32_to_cpu(rate);
 }
 
 static int scpi_clk_set_val(u16 clk_id, unsigned long rate)



[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