* [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
@ 2016-09-23 7:17 Madhavan Srinivasan
2016-09-23 8:09 ` Dave Young
2016-09-23 9:50 ` Pratyush Anand
0 siblings, 2 replies; 5+ messages in thread
From: Madhavan Srinivasan @ 2016-09-23 7:17 UTC (permalink / raw)
To: horms; +Cc: Madhavan Srinivasan, kexec
In dt_copy_old_root_param(), FILE * returned
from fopen is not checked for NULL pointer
before passinig to fclose(). This could trigger
a segfault. Patch adds a check.
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
kexec/fs2dt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index 6ed2399759cf..2c1ebdf525f4 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -540,7 +540,8 @@ static void dt_copy_old_root_param(void)
if (last_cmdline)
free(last_cmdline);
- fclose(fp);
+ if (fp)
+ fclose(fp);
}
/*
--
2.7.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
2016-09-23 7:17 [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param() Madhavan Srinivasan
@ 2016-09-23 8:09 ` Dave Young
2016-09-23 9:50 ` Pratyush Anand
1 sibling, 0 replies; 5+ messages in thread
From: Dave Young @ 2016-09-23 8:09 UTC (permalink / raw)
To: Madhavan Srinivasan; +Cc: horms, kexec
On 09/23/16 at 12:47pm, Madhavan Srinivasan wrote:
> In dt_copy_old_root_param(), FILE * returned
> from fopen is not checked for NULL pointer
> before passinig to fclose(). This could trigger
> a segfault. Patch adds a check.
>
> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> ---
> kexec/fs2dt.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 6ed2399759cf..2c1ebdf525f4 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -540,7 +540,8 @@ static void dt_copy_old_root_param(void)
> if (last_cmdline)
> free(last_cmdline);
>
> - fclose(fp);
> + if (fp)
> + fclose(fp);
> }
>
> /*
> --
> 2.7.4
>
>
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
Reviewed-by: Dave Young <dyoung@redhat.com>
Thanks
Dave
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
2016-09-23 7:17 [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param() Madhavan Srinivasan
2016-09-23 8:09 ` Dave Young
@ 2016-09-23 9:50 ` Pratyush Anand
2016-09-29 7:41 ` Simon Horman
1 sibling, 1 reply; 5+ messages in thread
From: Pratyush Anand @ 2016-09-23 9:50 UTC (permalink / raw)
To: Madhavan Srinivasan; +Cc: horms, kexec
On 23/09/2016:12:47:39 PM, Madhavan Srinivasan wrote:
> In dt_copy_old_root_param(), FILE * returned
> from fopen is not checked for NULL pointer
> before passinig to fclose(). This could trigger
> a segfault. Patch adds a check.
>
> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> ---
> kexec/fs2dt.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 6ed2399759cf..2c1ebdf525f4 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -540,7 +540,8 @@ static void dt_copy_old_root_param(void)
> if (last_cmdline)
> free(last_cmdline);
>
> - fclose(fp);
> + if (fp)
> + fclose(fp);
Looks fine, however a better practise could be to return just after fopen() if
fp was null.
~Pratyush
> }
>
> /*
> --
> 2.7.4
>
>
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
2016-09-23 9:50 ` Pratyush Anand
@ 2016-09-29 7:41 ` Simon Horman
2016-09-29 7:48 ` Madhavan Srinivasan
0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2016-09-29 7:41 UTC (permalink / raw)
To: Pratyush Anand; +Cc: Madhavan Srinivasan, kexec
On Fri, Sep 23, 2016 at 03:20:46PM +0530, Pratyush Anand wrote:
> On 23/09/2016:12:47:39 PM, Madhavan Srinivasan wrote:
> > In dt_copy_old_root_param(), FILE * returned
> > from fopen is not checked for NULL pointer
> > before passinig to fclose(). This could trigger
> > a segfault. Patch adds a check.
> >
> > Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> > ---
> > kexec/fs2dt.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> > index 6ed2399759cf..2c1ebdf525f4 100644
> > --- a/kexec/fs2dt.c
> > +++ b/kexec/fs2dt.c
> > @@ -540,7 +540,8 @@ static void dt_copy_old_root_param(void)
> > if (last_cmdline)
> > free(last_cmdline);
> >
> > - fclose(fp);
> > + if (fp)
> > + fclose(fp);
>
> Looks fine, however a better practise could be to return just after fopen() if
> fp was null.
That sounds like it would be somewhat cleaner.
Madhavan, could you see about making it so?
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
2016-09-29 7:41 ` Simon Horman
@ 2016-09-29 7:48 ` Madhavan Srinivasan
0 siblings, 0 replies; 5+ messages in thread
From: Madhavan Srinivasan @ 2016-09-29 7:48 UTC (permalink / raw)
To: Simon Horman, Pratyush Anand; +Cc: kexec
On Thursday 29 September 2016 01:11 PM, Simon Horman wrote:
> On Fri, Sep 23, 2016 at 03:20:46PM +0530, Pratyush Anand wrote:
>> On 23/09/2016:12:47:39 PM, Madhavan Srinivasan wrote:
>>> In dt_copy_old_root_param(), FILE * returned
>>> from fopen is not checked for NULL pointer
>>> before passinig to fclose(). This could trigger
>>> a segfault. Patch adds a check.
>>>
>>> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
>>> ---
>>> kexec/fs2dt.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
>>> index 6ed2399759cf..2c1ebdf525f4 100644
>>> --- a/kexec/fs2dt.c
>>> +++ b/kexec/fs2dt.c
>>> @@ -540,7 +540,8 @@ static void dt_copy_old_root_param(void)
>>> if (last_cmdline)
>>> free(last_cmdline);
>>>
>>> - fclose(fp);
>>> + if (fp)
>>> + fclose(fp);
>> Looks fine, however a better practise could be to return just after fopen() if
>> fp was null.
> That sounds like it would be somewhat cleaner.
> Madhavan, could you see about making it so?
Yep. re-spinning now.
Maddy
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-29 7:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23 7:17 [PATCH] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param() Madhavan Srinivasan
2016-09-23 8:09 ` Dave Young
2016-09-23 9:50 ` Pratyush Anand
2016-09-29 7:41 ` Simon Horman
2016-09-29 7:48 ` Madhavan Srinivasan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.