[PATCH v2] kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thursday 29 September 2016 01:29 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 to fix the same.
>
> Reviewed-by: Dave Young <dyoung at redhat.com>
> Signed-off-by: Madhavan Srinivasan <maddy at linux.vnet.ibm.com>

Reviewed-by: Pratyush Anand <panand at redhat.com>

> ---
> Changelog v1:
>  - Moved the check right after fopen
>
>  kexec/fs2dt.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
> index 6ed2399759cf..5ba3ec0fa65c 100644
> --- a/kexec/fs2dt.c
> +++ b/kexec/fs2dt.c
> @@ -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);
>



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux