Skip to content

Commit 4bcd9ea

Browse files
andy-shevgregkh
authored andcommitted
fbtft: Fix the initialization from property algorithm
When converting to device property API the commit 8b2d3ae ("fbtft: Make use of device property API") mistakenly placed the reading of the first value inside the loop, that jumps over value after initialization sequence or sleep commands. Move the above mentioned reading outside of the loop to restore correct behaviour. Besides that, we are using pre-increment operation which may lead to out of the boundary access at the end of sequence. Thus, allocate buffer with an additional element at the end to prevent out of the boundary access. Fixes: 8b2d3ae ("fbtft: Make use of device property API") Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c724f77 commit 4bcd9ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/staging/fbtft/fbtft-core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ static int fbtft_init_display_from_property(struct fbtft_par *par)
913913
if (count == 0)
914914
return -EINVAL;
915915

916-
values = kmalloc_array(count, sizeof(*values), GFP_KERNEL);
916+
values = kmalloc_array(count + 1, sizeof(*values), GFP_KERNEL);
917917
if (!values)
918918
return -ENOMEM;
919919

@@ -926,9 +926,9 @@ static int fbtft_init_display_from_property(struct fbtft_par *par)
926926
gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
927927

928928
index = -1;
929-
while (index < count) {
930-
val = values[++index];
929+
val = values[++index];
931930

931+
while (index < count) {
932932
if (val & FBTFT_OF_INIT_CMD) {
933933
val &= 0xFFFF;
934934
i = 0;

0 commit comments

Comments
 (0)