Skip to content

Commit 33e262a

Browse files
Fix incorrect array size in gpio_free_array call
The gpio_free_array function was incorrectly passed ARRAY_SIZE(leds) when freeing the 'buttons' array in multiple examples: - examples/intrp.c - examples/bottomhalf.c - examples/bh_halfthreaded.c This mismatch could lead to invalid memory access if the size of 'buttons' differs from 'leds'. Updated all occurrences to use ARRAY_SIZE(buttons) for correctness. Co-authored-by: EricccTaiwan <yphbchou0911@gmail.com> Signed-off-by: Jordan Chiu <jordan871130@gmail.com>
1 parent b4c2bf1 commit 33e262a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

examples/bh_threaded.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int __init bottomhalf_init(void)
171171
free_irq(button_irqs[0], &buttons[0]);
172172

173173
fail2:
174-
gpio_free_array(buttons, ARRAY_SIZE(leds));
174+
gpio_free_array(buttons, ARRAY_SIZE(buttons));
175175

176176
fail1:
177177
gpio_free_array(leds, ARRAY_SIZE(leds));

examples/bottomhalf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static int __init bottomhalf_init(void)
189189
free_irq(button_irqs[0], NULL);
190190

191191
fail2:
192-
gpio_free_array(buttons, ARRAY_SIZE(leds));
192+
gpio_free_array(buttons, ARRAY_SIZE(buttons));
193193

194194
fail1:
195195
gpio_free_array(leds, ARRAY_SIZE(leds));

examples/intrpt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int __init intrpt_init(void)
165165
free_irq(button_irqs[0], NULL);
166166

167167
fail2:
168-
gpio_free_array(buttons, ARRAY_SIZE(leds));
168+
gpio_free_array(buttons, ARRAY_SIZE(buttons));
169169

170170
fail1:
171171
gpio_free_array(leds, ARRAY_SIZE(leds));

0 commit comments

Comments
 (0)