[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMEuxRrg0nSroVGXwaCM1579Ddb822mY0hkSX5_Kcz1YqF_9sg@mail.gmail.com>
Date: Fri, 2 Sep 2022 23:25:31 -0700
From: Li Zhong <floridsleeves@...il.com>
To: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc: Greg KH <gregkh@...uxfoundation.org>, rafael@...nel.org
Subject: [PATCH v1] drivers/base/auxiliary: check return value of strrchr()
From: Li Zhong <floridsleeves@...il.com>
The return value of strrchr() could be NULL, which will cause invalid
offset in (int)(p - name). So we check it here.
Signed-off-by: Li Zhong <floridsleeves@...il.com>
---
drivers/base/auxiliary.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index 8c5e65930617..7ac23be47e1f 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -191,7 +191,8 @@ static int auxiliary_uevent(struct device *dev,
struct kobj_uevent_env *env)
name = dev_name(dev);
p = strrchr(name, '.');
-
+ if (!p)
+ return -EINVAL;
return add_uevent_var(env, "MODALIAS=%s%.*s", AUXILIARY_MODULE_PREFIX,
(int)(p - name), name);
}
--
2.25.1
Powered by blists - more mailing lists