lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 6 May 2020 14:27:58 +0200
From:   Hannes Reinecke <hare@...e.de>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        satishkh@...co.com, sebaddel@...co.com, kartilak@...co.com,
        jejb@...ux.ibm.com, martin.petersen@...cle.com
Cc:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] scsi: fnic: Use kmalloc instead of vmalloc for a small
 memory allocation

On 4/23/20 10:46 PM, Christophe JAILLET wrote:
> 'struct fc_trace_flag_type' is just a few bytes long. There is no need
> to allocate such a structure with vmalloc. Using kmalloc instead.
> 
> While at it, axe a useless test when freeing the memory.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
>   drivers/scsi/fnic/fnic_debugfs.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
> index 13f7d88d6e57..8d6ce3470594 100644
> --- a/drivers/scsi/fnic/fnic_debugfs.c
> +++ b/drivers/scsi/fnic/fnic_debugfs.c
> @@ -58,8 +58,7 @@ int fnic_debugfs_init(void)
>   						fnic_trace_debugfs_root);
>   
>   	/* Allocate memory to structure */
> -	fc_trc_flag = (struct fc_trace_flag_type *)
> -		vmalloc(sizeof(struct fc_trace_flag_type));
> +	fc_trc_flag = kmalloc(sizeof(*fc_trc_flag), GFP_KERNEL);
>   
>   	if (fc_trc_flag) {
>   		fc_trc_flag->fc_row_file = 0;
> @@ -87,8 +86,7 @@ void fnic_debugfs_terminate(void)
>   	debugfs_remove(fnic_trace_debugfs_root);
>   	fnic_trace_debugfs_root = NULL;
>   
> -	if (fc_trc_flag)
> -		vfree(fc_trc_flag);
> +	kfree(fc_trc_flag);
>   }
>   
>   /*
> 
Reviewed-by: Hannes Reinecke <har@...e.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke            Teamlead Storage & Networking
hare@...e.de                               +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ