| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 7316a9e5720c2f4112a96b32c4ec78d94a44adcf Mon Sep 17 00:00:00 2001 |
| 2 | From: popcornmix <popcornmix@gmail.com> |
| 3 | Date: Tue, 6 Aug 2019 15:23:14 +0100 |
| 4 | Subject: [PATCH] clk-bcm2835: Avoid null pointer exception |
| 5 | |
| 6 | clk_desc_array[BCM2835_PLLB] doesn't exist so we dereference null when iterating |
| 7 | |
| 8 | Signed-off-by: popcornmix <popcornmix@gmail.com> |
| 9 | --- |
| 10 | drivers/clk/bcm/clk-bcm2835.c | 8 +++++--- |
| 11 | 1 file changed, 5 insertions(+), 3 deletions(-) |
| 12 | |
| 13 | --- a/drivers/clk/bcm/clk-bcm2835.c |
| 14 | +++ b/drivers/clk/bcm/clk-bcm2835.c |
| 15 | @@ -2275,9 +2275,11 @@ static bool bcm2835_clk_is_claimed(const |
| 16 | int i; |
| 17 | |
| 18 | for (i = 0; i < ARRAY_SIZE(clk_desc_array); i++) { |
| 19 | - const char *clk_name = *(const char **)(clk_desc_array[i].data); |
| 20 | - if (!strcmp(name, clk_name)) |
| 21 | - return bcm2835_clk_claimed[i]; |
| 22 | + if (clk_desc_array[i].data) { |
| 23 | + const char *clk_name = *(const char **)(clk_desc_array[i].data); |
| 24 | + if (!strcmp(name, clk_name)) |
| 25 | + return bcm2835_clk_claimed[i]; |
| 26 | + } |
| 27 | } |
| 28 | |
| 29 | return false; |