Re: [DKIM] [PATCH 2/2] media: siano: Fix the missing err path in smsdvb_debugfs_create()

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

 



On 14/09/2023 05:50, Jinjie Ruan wrote:
> If kzalloc() fails in smsdvb_debugfs_create(), the dir and file which
> is created by debugfs_create_dir() and debugfs_create_file() is
> not freed. So use debugfs_remove_recursive() to free them.
> 
> Fixes: 503efe5cfc9f ("[media] siano: split debugfs code into a separate file")
> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
> ---
>  drivers/media/common/siano/smsdvb-debugfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c
> index 16d3b9ab31c5..38b25e88ce57 100644
> --- a/drivers/media/common/siano/smsdvb-debugfs.c
> +++ b/drivers/media/common/siano/smsdvb-debugfs.c
> @@ -375,8 +375,10 @@ int smsdvb_debugfs_create(struct smsdvb_client_t *client)
>  	}
>  
>  	debug_data = kzalloc(sizeof(*client->debug_data), GFP_KERNEL);
> -	if (!debug_data)
> +	if (!debug_data) {
> +		debugfs_remove_recursive(client->debugfs);
>  		return -ENOMEM;
> +	}
>  
>  	client->debug_data        = debug_data;
>  	client->prt_dvb_stats     = smsdvb_print_dvb_stats;

It's much better to first allocate debug_data before calling debugfs_create_dir.

No need to clean anything up in that case.

You can also ignore any errors from debugfs_create_file.

Regards,

	Hans



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux