From f02997c3ed57888288e2f133e36a8440d9e77626 Mon Sep 17 00:00:00 2001
From: Przemyslaw Marczak
Date: Fri, 28 Nov 2014 14:27:21 +0100
Subject: [PATCH] f_thor: check pointer before use in downlaod_tail()
Change-Id: Ic0be6b313eb293f607192b9fddf3b8f911ab91bd
Signed-off-by: Przemyslaw Marczak
---
drivers/usb/gadget/f_thor.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
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,
--
2.7.4