Skip to content
Snippets Groups Projects
Commit e059a400 authored by Łukasz Majewski's avatar Łukasz Majewski Committed by Marek Vasut
Browse files

dfu:function: Fix number of allocated DFU function pointers


This subtle change fix problem with too small amount of allocated
memory to store DFU function pointers.

One needs to allocate extra space for sentinel NULL pointer in this array
of function pointers.

With the previous code, the NULL value overwrites malloc internal data
and afterwards free(f_dfu->function) crashes.

Signed-off-by: default avatarLukasz Majewski <l.majewski@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Vasut <marex@denx.de>
parent 7a342785
No related branches found
No related tags found
No related merge requests found
......@@ -589,7 +589,7 @@ static int dfu_prepare_function(struct f_dfu *f_dfu, int n)
struct usb_interface_descriptor *d;
int i = 0;
f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n);
f_dfu->function = calloc(sizeof(struct usb_descriptor_header *), n + 1);
if (!f_dfu->function)
goto enomem;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment