From: Przemyslaw Marczak Date: Fri, 28 Nov 2014 13:27:21 +0000 (+0100) Subject: f_thor: check pointer before use in downlaod_tail() X-Git-Tag: accepted/tizen/common/20141210.130049~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f02997c3ed57888288e2f133e36a8440d9e77626;p=platform%2Fkernel%2Fu-boot.git f_thor: check pointer before use in downlaod_tail() Change-Id: Ic0be6b313eb293f607192b9fddf3b8f911ab91bd Signed-off-by: Przemyslaw Marczak --- diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c index ef06a5a..fc7f220 100644 --- a/drivers/usb/gadget/f_thor.c +++ b/drivers/usb/gadget/f_thor.c @@ -215,12 +215,25 @@ static long long int download_head(unsigned long long total, static int download_tail(long long int left, int cnt) { - struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num); - void *transfer_buffer = dfu_get_buf(dfu_entity); + struct dfu_entity *dfu_entity; + void *transfer_buffer; int ret; debug("%s: left: %llu cnt: %d\n", __func__, left, cnt); + dfu_entity = dfu_get_entity(alt_setting_num); + if (!dfu_entity) { + printf("Alt setting: %d entity not found!\n", alt_setting_num); + return -ENOENT; + } + + transfer_buffer = dfu_get_buf(dfu_entity); + if (!transfer_buffer) { + printf("Alt setting: %d transfer buffer is NULL!\n", + alt_setting_num); + return -ENXIO; + } + #ifdef CONFIG_SIG /* check board signature when download u-boot-mmc.bin */ ret = check_board_signature(f_name, (phys_addr_t)transfer_buffer,