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>
if (!ctx)
return;
- pthread_cancel(ctx->thread);
+ if (ctx->thread)
+ pthread_cancel(ctx->thread);
destroy_dfu_info(ctx);
free(ctx);
}