drivers/base/auxiliary: check return value of strrchr()
Subsystems (2)
PATCH v2 1/1 drivers/base/auxiliary: check return value of strrchr()
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 <[email protected]>
--- drivers/base/auxiliary.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/base/auxiliary.c +2 -0
@@ -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);
Signature · 1 line
2.25.1
Greg KH
maintainerQuoted 13 lines · Li Zhong
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 <[email protected]>--- drivers/base/auxiliary.c | 2 ++ 1 file changed, 2 insertions(+)drivers/base/auxiliary.c +0
-0
drivers/base/auxiliary.c static int auxiliary_uevent(struct device *dev, struct kobj_uevent_env *env) · line 195
Quoted 5 lines
drivers/base/auxiliary.c +2
-0@@ -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 ;
How can that ever happen? For what device will that be triggered?
And again, please follow Documentation/process/researcher-guidelines.rst