[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CWXP265MB2680094534A5559B0A904B76C4089@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM>
Date: Wed, 23 Jun 2021 14:47:35 +0000
From: Christian Löhle <CLoehle@...erstone.com>
To: "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Christian Löhle <CLoehle@...erstone.com>
CC: "rafael@...nel.org" <rafael@...nel.org>
Subject: [PATCH] kobject: Safe return of kobject_get_path with NULL
Prevent NULL dereference within get_kobj_path_length
Calling kobject_get_path could provoke a NULL dereference
if NULL was passed. while fill_kobj_path will return
with a sane 0 for NULL, kobjet_get_path_length did not.
Signed-off-by: Christian Loehle <cloehle@...erstone.com>
---
lib/kobject.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/kobject.c b/lib/kobject.c
index ea53b30cf483..735159c13a94 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -130,6 +130,8 @@ static int get_kobj_path_length(struct kobject *kobj)
{
int length = 1;
struct kobject *parent = kobj;
+ if (!kobj)
+ return 0;
/* walk up the ancestors until we hit the one pointing to the
* root.
--
2.32.0
Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
Managing Directors: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782
Powered by blists - more mailing lists