* [PATCH][next] lkdtm: remove redundant initialization of ret
@ 2019-06-14 9:43 Colin King
2019-06-20 18:13 ` Kees Cook
2019-06-21 14:03 ` Greg Kroah-Hartman
0 siblings, 2 replies; 7+ messages in thread
From: Colin King @ 2019-06-14 9:43 UTC (permalink / raw)
To: Kees Cook, Arnd Bergmann, Greg Kroah-Hartman
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The variable ret is being initialized with the value -EINVAL however
this value is never read and ret is being re-assigned later on. Hence
the initialization is redundant and can be removed.
Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/misc/lkdtm/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
index bba093224813..92df35fdeab0 100644
--- a/drivers/misc/lkdtm/core.c
+++ b/drivers/misc/lkdtm/core.c
@@ -390,7 +390,7 @@ static int __init lkdtm_module_init(void)
{
struct crashpoint *crashpoint = NULL;
const struct crashtype *crashtype = NULL;
- int ret = -EINVAL;
+ int ret;
int i;
/* Neither or both of these need to be set */
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH][next] lkdtm: remove redundant initialization of ret
2019-06-14 9:43 [PATCH][next] lkdtm: remove redundant initialization of ret Colin King
@ 2019-06-20 18:13 ` Kees Cook
2019-06-21 13:50 ` Greg Kroah-Hartman
2019-06-21 14:03 ` Greg Kroah-Hartman
1 sibling, 1 reply; 7+ messages in thread
From: Kees Cook @ 2019-06-20 18:13 UTC (permalink / raw)
To: Colin King, Greg Kroah-Hartman
Cc: Arnd Bergmann, kernel-janitors, linux-kernel
On Fri, Jun 14, 2019 at 10:43:11AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The variable ret is being initialized with the value -EINVAL however
> this value is never read and ret is being re-assigned later on. Hence
> the initialization is redundant and can be removed.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks!
Acked-by: Kees Cook <keescook@chromium.org>
Greg, can you take this please?
-Kees
> ---
> drivers/misc/lkdtm/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
> index bba093224813..92df35fdeab0 100644
> --- a/drivers/misc/lkdtm/core.c
> +++ b/drivers/misc/lkdtm/core.c
> @@ -390,7 +390,7 @@ static int __init lkdtm_module_init(void)
> {
> struct crashpoint *crashpoint = NULL;
> const struct crashtype *crashtype = NULL;
> - int ret = -EINVAL;
> + int ret;
> int i;
>
> /* Neither or both of these need to be set */
> --
> 2.20.1
>
--
Kees Cook
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH][next] lkdtm: remove redundant initialization of ret
2019-06-20 18:13 ` Kees Cook
@ 2019-06-21 13:50 ` Greg Kroah-Hartman
0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-21 13:50 UTC (permalink / raw)
To: Kees Cook; +Cc: Colin King, Arnd Bergmann, kernel-janitors, linux-kernel
On Thu, Jun 20, 2019 at 11:13:32AM -0700, Kees Cook wrote:
> On Fri, Jun 14, 2019 at 10:43:11AM +0100, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > The variable ret is being initialized with the value -EINVAL however
> > this value is never read and ret is being re-assigned later on. Hence
> > the initialization is redundant and can be removed.
> >
> > Addresses-Coverity: ("Unused value")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Thanks!
>
> Acked-by: Kees Cook <keescook@chromium.org>
>
> Greg, can you take this please?
Will do, thanks.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH][next] lkdtm: remove redundant initialization of ret
2019-06-14 9:43 [PATCH][next] lkdtm: remove redundant initialization of ret Colin King
2019-06-20 18:13 ` Kees Cook
@ 2019-06-21 14:03 ` Greg Kroah-Hartman
2019-06-21 14:05 ` Greg Kroah-Hartman
1 sibling, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-21 14:03 UTC (permalink / raw)
To: Colin King; +Cc: Kees Cook, Arnd Bergmann, kernel-janitors, linux-kernel
On Fri, Jun 14, 2019 at 10:43:11AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The variable ret is being initialized with the value -EINVAL however
> this value is never read and ret is being re-assigned later on. Hence
> the initialization is redundant and can be removed.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Acked-by: Kees Cook <keescook@chromium.org>
> ---
> drivers/misc/lkdtm/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
> index bba093224813..92df35fdeab0 100644
> --- a/drivers/misc/lkdtm/core.c
> +++ b/drivers/misc/lkdtm/core.c
> @@ -390,7 +390,7 @@ static int __init lkdtm_module_init(void)
> {
> struct crashpoint *crashpoint = NULL;
> const struct crashtype *crashtype = NULL;
> - int ret = -EINVAL;
> + int ret;
> int i;
>
> /* Neither or both of these need to be set */
> --
> 2.20.1
>
With this patch now applied, I get this build warning:
drivers/misc/lkdtm/core.c: In function lkdtm_module_init:
drivers/misc/lkdtm/core.c:467:9: warning: ret may be used uninitialized in this function [-Wmaybe-uninitialized]
return ret;
^~~
So are you _sure_ it shouldn't be initialized?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH][next] lkdtm: remove redundant initialization of ret
2019-06-21 14:03 ` Greg Kroah-Hartman
@ 2019-06-21 14:05 ` Greg Kroah-Hartman
2019-06-21 16:26 ` Kees Cook
0 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-21 14:05 UTC (permalink / raw)
To: Colin King; +Cc: Kees Cook, Arnd Bergmann, kernel-janitors, linux-kernel
On Fri, Jun 21, 2019 at 04:03:47PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Jun 14, 2019 at 10:43:11AM +0100, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > The variable ret is being initialized with the value -EINVAL however
> > this value is never read and ret is being re-assigned later on. Hence
> > the initialization is redundant and can be removed.
> >
> > Addresses-Coverity: ("Unused value")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > Acked-by: Kees Cook <keescook@chromium.org>
> > ---
> > drivers/misc/lkdtm/core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
> > index bba093224813..92df35fdeab0 100644
> > --- a/drivers/misc/lkdtm/core.c
> > +++ b/drivers/misc/lkdtm/core.c
> > @@ -390,7 +390,7 @@ static int __init lkdtm_module_init(void)
> > {
> > struct crashpoint *crashpoint = NULL;
> > const struct crashtype *crashtype = NULL;
> > - int ret = -EINVAL;
> > + int ret;
> > int i;
> >
> > /* Neither or both of these need to be set */
> > --
> > 2.20.1
> >
>
> With this patch now applied, I get this build warning:
> drivers/misc/lkdtm/core.c: In function lkdtm_module_init:
> drivers/misc/lkdtm/core.c:467:9: warning: ret may be used uninitialized in this function [-Wmaybe-uninitialized]
> return ret;
> ^~~
>
> So are you _sure_ it shouldn't be initialized?
In looking at the code in my tree, ret is used uninitialized with this
patch, so maybe coverity is wrong, or I don't have all of the needed
patches?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH][next] lkdtm: remove redundant initialization of ret
2019-06-21 14:05 ` Greg Kroah-Hartman
@ 2019-06-21 16:26 ` Kees Cook
2019-06-23 5:00 ` Greg Kroah-Hartman
0 siblings, 1 reply; 7+ messages in thread
From: Kees Cook @ 2019-06-21 16:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Colin King, Arnd Bergmann, kernel-janitors, linux-kernel
On Fri, Jun 21, 2019 at 04:05:09PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Jun 21, 2019 at 04:03:47PM +0200, Greg Kroah-Hartman wrote:
> > On Fri, Jun 14, 2019 at 10:43:11AM +0100, Colin King wrote:
> > > From: Colin Ian King <colin.king@canonical.com>
> > >
> > > The variable ret is being initialized with the value -EINVAL however
> > > this value is never read and ret is being re-assigned later on. Hence
> > > the initialization is redundant and can be removed.
> > >
> > > Addresses-Coverity: ("Unused value")
> > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > Acked-by: Kees Cook <keescook@chromium.org>
> > > ---
> > > drivers/misc/lkdtm/core.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
> > > index bba093224813..92df35fdeab0 100644
> > > --- a/drivers/misc/lkdtm/core.c
> > > +++ b/drivers/misc/lkdtm/core.c
> > > @@ -390,7 +390,7 @@ static int __init lkdtm_module_init(void)
> > > {
> > > struct crashpoint *crashpoint = NULL;
> > > const struct crashtype *crashtype = NULL;
> > > - int ret = -EINVAL;
> > > + int ret;
> > > int i;
> > >
> > > /* Neither or both of these need to be set */
> > > --
> > > 2.20.1
> > >
> >
> > With this patch now applied, I get this build warning:
> > drivers/misc/lkdtm/core.c: In function lkdtm_module_init:
> > drivers/misc/lkdtm/core.c:467:9: warning: ret may be used uninitialized in this function [-Wmaybe-uninitialized]
> > return ret;
> > ^~~
> >
> > So are you _sure_ it shouldn't be initialized?
>
> In looking at the code in my tree, ret is used uninitialized with this
> patch, so maybe coverity is wrong, or I don't have all of the needed
> patches?
The path went away when the check for debugfs_create_file() was removed.
I thought that patch was in your tree already?
In master, this is the path to "return ret" without prior assignment:
de = debugfs_create_file(cur->name, 0644, lkdtm_debugfs_root,
cur, &cur->fops);
if (de = NULL) {
pr_err("could not create crashpoint %s\n", cur->name);
goto out_err;
}
--
Kees Cook
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH][next] lkdtm: remove redundant initialization of ret
2019-06-21 16:26 ` Kees Cook
@ 2019-06-23 5:00 ` Greg Kroah-Hartman
0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-23 5:00 UTC (permalink / raw)
To: Kees Cook; +Cc: Colin King, Arnd Bergmann, kernel-janitors, linux-kernel
On Fri, Jun 21, 2019 at 09:26:05AM -0700, Kees Cook wrote:
> On Fri, Jun 21, 2019 at 04:05:09PM +0200, Greg Kroah-Hartman wrote:
> > On Fri, Jun 21, 2019 at 04:03:47PM +0200, Greg Kroah-Hartman wrote:
> > > On Fri, Jun 14, 2019 at 10:43:11AM +0100, Colin King wrote:
> > > > From: Colin Ian King <colin.king@canonical.com>
> > > >
> > > > The variable ret is being initialized with the value -EINVAL however
> > > > this value is never read and ret is being re-assigned later on. Hence
> > > > the initialization is redundant and can be removed.
> > > >
> > > > Addresses-Coverity: ("Unused value")
> > > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > > Acked-by: Kees Cook <keescook@chromium.org>
> > > > ---
> > > > drivers/misc/lkdtm/core.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
> > > > index bba093224813..92df35fdeab0 100644
> > > > --- a/drivers/misc/lkdtm/core.c
> > > > +++ b/drivers/misc/lkdtm/core.c
> > > > @@ -390,7 +390,7 @@ static int __init lkdtm_module_init(void)
> > > > {
> > > > struct crashpoint *crashpoint = NULL;
> > > > const struct crashtype *crashtype = NULL;
> > > > - int ret = -EINVAL;
> > > > + int ret;
> > > > int i;
> > > >
> > > > /* Neither or both of these need to be set */
> > > > --
> > > > 2.20.1
> > > >
> > >
> > > With this patch now applied, I get this build warning:
> > > drivers/misc/lkdtm/core.c: In function lkdtm_module_init:
> > > drivers/misc/lkdtm/core.c:467:9: warning: ret may be used uninitialized in this function [-Wmaybe-uninitialized]
> > > return ret;
> > > ^~~
> > >
> > > So are you _sure_ it shouldn't be initialized?
> >
> > In looking at the code in my tree, ret is used uninitialized with this
> > patch, so maybe coverity is wrong, or I don't have all of the needed
> > patches?
>
> The path went away when the check for debugfs_create_file() was removed.
> I thought that patch was in your tree already?
Ah, other tree, sorry, my fault. I'll go queue this up to the place
that patch is...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-06-23 5:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 9:43 [PATCH][next] lkdtm: remove redundant initialization of ret Colin King
2019-06-20 18:13 ` Kees Cook
2019-06-21 13:50 ` Greg Kroah-Hartman
2019-06-21 14:03 ` Greg Kroah-Hartman
2019-06-21 14:05 ` Greg Kroah-Hartman
2019-06-21 16:26 ` Kees Cook
2019-06-23 5:00 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).