summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2020-09-22 14:20:48 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2020-09-22 14:20:51 +0900
commitb81b7d964400a40c3839c5e9c9cadd7b97a00f8c (patch)
treee774bd93aa7d590380115ac58b002a5bfe4654a2
parent61d264453cf5c0abdd5ff013ea3a3c13f84142aa (diff)
downloadinitrd-flash-b81b7d964400a40c3839c5e9c9cadd7b97a00f8c.tar.gz
initrd-flash-b81b7d964400a40c3839c5e9c9cadd7b97a00f8c.tar.bz2
initrd-flash-b81b7d964400a40c3839c5e9c9cadd7b97a00f8c.zip
dfu: add null check for thread
If dfu_start() is failed, there are cases ctx->thread is null and this causes crash during dfu_free_context(). So add null check for thread from dfu_free_context(). This fixes below crash-stack: Call Stack Count: 2 0: pthread_cancel + 0x10 (0x0000007f81d9eab0) [/mnt/initrd-recovery/usr/lib64/libpthread.so.0] + 0x10ab0 1: dfu_free_context + 0x1c (0x000000557ca2283c) [/mnt/initrd-recovery/usr/bin/flash-manager] + 0x483c End of Call Stack Change-Id: I92fb9980047a3a58de516e81d694b7507662be26 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r--src/dfu.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dfu.c b/src/dfu.c
index c7d1039..362016a 100644
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -644,7 +644,8 @@ void dfu_free_context(struct dfu_context *ctx)
if (!ctx)
return;
- pthread_cancel(ctx->thread);
+ if (ctx->thread)
+ pthread_cancel(ctx->thread);
destroy_dfu_info(ctx);
free(ctx);
}