Patch "clk: bcm: rpi: Fix off by one in raspberrypi_discover_clocks()" has been added to the 6.1-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

    clk: bcm: rpi: Fix off by one in raspberrypi_discover_clocks()

to the 6.1-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:
     clk-bcm-rpi-fix-off-by-one-in-raspberrypi_discover_c.patch
and it can be found in the queue-6.1 subdirectory.

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



commit 47da85e18961fae51330844cc208dfa547b9b71e
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Fri Apr 21 13:41:01 2023 +0300

    clk: bcm: rpi: Fix off by one in raspberrypi_discover_clocks()
    
    [ Upstream commit da2edb3e3c09fd1451b7f400ccd1070ef086619a ]
    
    Smatch detected an off by one in this code:
        drivers/clk/bcm/clk-raspberrypi.c:374 raspberrypi_discover_clocks()
        error: buffer overflow 'data->hws' 16 <= 16
    
    The data->hws[] array has RPI_FIRMWARE_NUM_CLK_ID elements so the >
    comparison needs to changed to >=.
    
    Fixes: 12c90f3f27bb ("clk: bcm: rpi: Add variant structure")
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/5a850b08-d2f5-4794-aceb-a6b468965139@kili.mountain
    Reviewed-by: Stefan Wahren <stefan.wahren@xxxxxxxx>
    Reviewed-by: Florian Fainelli <f.fainelli@xxxxxxxxx>
    Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 679f4649a7efd..278f845572813 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -375,9 +375,9 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
 	while (clks->id) {
 		struct raspberrypi_clk_variant *variant;
 
-		if (clks->id > RPI_FIRMWARE_NUM_CLK_ID) {
+		if (clks->id >= RPI_FIRMWARE_NUM_CLK_ID) {
 			dev_err(rpi->dev, "Unknown clock id: %u (max: %u)\n",
-					   clks->id, RPI_FIRMWARE_NUM_CLK_ID);
+					   clks->id, RPI_FIRMWARE_NUM_CLK_ID - 1);
 			return -EINVAL;
 		}
 



[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