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]
Message-ID: <Y82AHjrNAaWq2yt2@ubun2204.myguest.virtualbox.org>
Date:   Sun, 22 Jan 2023 23:57:42 +0530
From:   Deepak R Varma <drv@...lo.com>
To:     Kashyap Desai <kashyap.desai@...adcom.com>,
        Sumit Saxena <sumit.saxena@...adcom.com>,
        Shivasharan S <shivasharan.srikanteshwara@...adcom.com>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        megaraidlinux.pdl@...adcom.com, linux-scsi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     Saurabh Singh Sengar <ssengar@...rosoft.com>,
        Praveen Kumar <kumarpraveen@...ux.microsoft.com>
Subject: Re: [PATCH] scsi: megaraid_sas: Use a variable for repeated mem_size
 computation

On Thu, Jan 12, 2023 at 12:17:27AM +0530, Deepak R Varma wrote:
> Use a variable to upfront compute memory size to be allocated,
> instead of repeatedly computing it at different instructions.
> The reduced instruction length also allows to tidy up the code.
> Issue identified using the array_size_dup Coccinelle semantic
> patch.
> 
> Signed-off-by: Deepak R Varma <drv@...lo.com>
> ---

Hello,
May I request a review and feedback comments on this patch proposal please?

Thank you,
./drv

>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> index fe70f8f11435..efb25af80664 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> @@ -5287,6 +5287,7 @@ int
>  megasas_alloc_fusion_context(struct megasas_instance *instance)
>  {
>  	struct fusion_context *fusion;
> +	size_t sz;
>  
>  	instance->ctrl_context = kzalloc(sizeof(struct fusion_context),
>  					 GFP_KERNEL);
> @@ -5298,15 +5299,13 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
>  
>  	fusion = instance->ctrl_context;
>  
> -	fusion->log_to_span_pages = get_order(MAX_LOGICAL_DRIVES_EXT *
> -					      sizeof(LD_SPAN_INFO));
> +	sz = array_size(MAX_LOGICAL_DRIVES_EXT, sizeof(LD_SPAN_INFO));
> +	fusion->log_to_span_pages = get_order(sz);
>  	fusion->log_to_span =
>  		(PLD_SPAN_INFO)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
>  						fusion->log_to_span_pages);
>  	if (!fusion->log_to_span) {
> -		fusion->log_to_span =
> -			vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT,
> -					   sizeof(LD_SPAN_INFO)));
> +		fusion->log_to_span = vzalloc(sz);
>  		if (!fusion->log_to_span) {
>  			dev_err(&instance->pdev->dev, "Failed from %s %d\n",
>  				__func__, __LINE__);
> @@ -5314,15 +5313,13 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
>  		}
>  	}
>  
> -	fusion->load_balance_info_pages = get_order(MAX_LOGICAL_DRIVES_EXT *
> -		sizeof(struct LD_LOAD_BALANCE_INFO));
> +	sz = array_size(MAX_LOGICAL_DRIVES_EXT, sizeof(struct LD_LOAD_BALANCE_INFO));
> +	fusion->load_balance_info_pages = get_order(sz);
>  	fusion->load_balance_info =
>  		(struct LD_LOAD_BALANCE_INFO *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
>  		fusion->load_balance_info_pages);
>  	if (!fusion->load_balance_info) {
> -		fusion->load_balance_info =
> -			vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT,
> -					   sizeof(struct LD_LOAD_BALANCE_INFO)));
> +		fusion->load_balance_info = vzalloc(sz);
>  		if (!fusion->load_balance_info)
>  			dev_err(&instance->pdev->dev, "Failed to allocate load_balance_info, "
>  				"continuing without Load Balance support\n");
> -- 
> 2.34.1
> 
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ