lkml.org 
[lkml]   [2022]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] drivers/base/auxiliary: check return value of strrchr()
Date
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@gmail.com>
---
drivers/base/auxiliary.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index 8c5e65930617..2ec0306bfba3 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -191,6 +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
\
 
 \ /
  Last update: 2022-09-04 02:53    [W:0.027 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site