[PATCH 14/32] bthread: fix null pointer dereference in error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When borting bthread creation early, we would end up calling
bthread_free on a NULL bthread, causing a NULL pointer dereference.

As it's customary for free functions to gracefully handle a NULL
argument, have bthread_free follow suit.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 common/bthread.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/bthread.c b/common/bthread.c
index 46e6987149bb..d40c0b0f9e3a 100644
--- a/common/bthread.c
+++ b/common/bthread.c
@@ -70,6 +70,8 @@ bool bthread_is_main(struct bthread *bthread)
 
 static void bthread_free(struct bthread *bthread)
 {
+	if (!bthread)
+		return;
 	free(bthread->stack);
 	free(bthread->name);
 	free(bthread);
-- 
2.30.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux