kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
Subsystems (2)
PATCH v2 1/1 kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
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 to fix the same.
---
Changelog v1:
- Moved the check right after fopen
kexec/fs2dt.c | 3 +++ 1 file changed, 3 insertions(+)
kexec/fs2dt.c +3 -0
@@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)strcpy (filename, pathname);strcat (filename,"bootargs" ); fp =fopen (filename,"r" ); +if (!fp) +return ; +if (fp) {if (getline (&last_cmdline, &len, fp) ==-1 )die ("unable to read %s\n" , filename);
Signature · 7 lines
2.7.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
[CC Dave Young]
Quoted 6 lines · Madhavan Srinivasan
In
dt_copy_old_root_param(), FILE * returned from fopen is not checked for NULL pointer before passinig tofclose(). This could trigger a segfault. Patch to fix the same.Reviewed-by Dave Young <[email protected]>
Probably Dave's tag should be dropped as that was for a somewhat different (though equally trivial) approach.
Quoted 13 lines
Signed-off-by Madhavan Srinivasan <[email protected]>---
Changelog v1:
- Moved the check right after fopenkexec/fs2dt.c | 3 +++ 1 file changed, 3 insertions(+)kexec/fs2dt.c +0
-0
kexec/fs2dt.c static void dt_copy_old_root_param(void) · line 529
Quoted 6 lines
kexec/fs2dt.c +3
-0@@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)strcpy (filename, pathname);strcat (filename,"bootargs" ); fp =fopen (filename,"r" ); +if (!fp) +return ; +
With the (!fp) conditional above the (fp) conditional below can be removed.
Quoted 6 lines
kexec/fs2dt.c +0
-0if (fp) {if (getline (&last_cmdline, &len, fp) ==-1 )die ("unable to read %s\n" , filename);Signature · 1 line
2.7.4
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 8 lines · Simon Horman
[CC Dave Young]
Quoted 5 lines · Madhavan Srinivasan
In
dt_copy_old_root_param(), FILE * returned from fopen is not checked for NULL pointer before passinig tofclose(). This could trigger a segfault. Patch to fix the same.
Quoted 4 lines
Quoted 1 line
Reviewed-by Dave Young <[email protected]>Probably Dave's tag should be dropped as that was for a somewhat different (though equally trivial) approach.
Simion, I think I'm fine with any of them.
Quoted 9 lines
Quoted 9 lines
Signed-off-by Madhavan Srinivasan <[email protected]>---
Changelog v1:
- Moved the check right after fopenkexec/fs2dt.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 20 lines
kexec/fs2dt.c static void dt_copy_old_root_param(void) · line 529
Quoted 11 lines
kexec/fs2dt.c +3
-0@@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)strcpy (filename, pathname);strcat (filename,"bootargs" ); fp =fopen (filename,"r" ); +if (!fp) +return ; +With the (!fp) conditional above the (fp) conditional below can be removed.
Quoted 6 lines
kexec/fs2dt.c +0
-0if (fp) {if (getline (&last_cmdline, &len, fp) ==-1 )die ("unable to read %s\n" , filename);Signature · 1 line
2.7.4
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 7 lines · Madhavan Srinivasan
In
dt_copy_old_root_param(), FILE * returned from fopen is not checked for NULL pointer before passinig tofclose(). This could trigger a segfault. Patch to fix the same.Reviewed-by Dave Young <[email protected]>Signed-off-by Madhavan Srinivasan <[email protected]>
Quoted 13 lines
---
Changelog v1:
- Moved the check right after fopenkexec/fs2dt.c | 3 +++ 1 file changed, 3 insertions(+)kexec/fs2dt.c +0
-0
kexec/fs2dt.c static void dt_copy_old_root_param(void) · line 532
Quoted 9 lines
kexec/fs2dt.c +3
-0@@ -524,6 +524,9 @@ static void dt_copy_old_root_param(void)strcpy (filename, pathname);strcat (filename,"bootargs" ); fp =fopen (filename,"r" ); +if (!fp) +return ; +if (fp) {if (getline (&last_cmdline, &len, fp) ==-1 )die ("unable to read %s\n" , filename);
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec