[PATCH 4/5] ubifs: fix potential NULL ptr dereference

Sascha Hauer s.hauer at pengutronix.de
Thu Jul 7 00:15:28 PDT 2016


On Wed, Jul 06, 2016 at 09:32:51PM +0200, Lucas Stach wrote:
> Signed-off-by: Lucas Stach <dev at lynxeye.de>
> ---
>  fs/ubifs/ubifs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 8062baa..bc1b521 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -479,7 +479,7 @@ out:
>  		dbg_gen("cannot find next direntry, error %d", err);
>  
>  out_free:
> -	if (file->private_data)
> +	if (file && file->private_data)
>  		kfree(file->private_data);
>  	if (file)
>  		free(file);

We should rather use xzalloc, then we could drop all the if() in the
error path.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list