2022-08-28 20:46:54

by Li Zhong

[permalink] [raw]
Subject: [PATCH v1] drivers/base/auxiliary: check return value of strrchr()

From: lily <[email protected]>

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 | 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


2022-09-01 15:39:22

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v1] drivers/base/auxiliary: check return value of strrchr()

On Sun, Aug 28, 2022 at 01:40:40PM -0700, Li Zhong wrote:
> From: lily <[email protected]>
>
> 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 | 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
>

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- It looks like you did not use your "real" name for the patch on either
the Signed-off-by: line, or the From: line (both of which have to
match). Please read the kernel file, Documentation/SubmittingPatches
for how to do this correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

2022-09-03 06:44:29

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v1] drivers/base/auxiliary: check return value of strrchr()

On Fri, Sep 02, 2022 at 11:25:31PM -0700, Li Zhong wrote:
> From: Li Zhong <[email protected]>
>
> 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 | 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

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
and can not be applied. Please read the file,
Documentation/email-clients.txt in order to fix this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot