Re: [PATCH v5 10/11] platform/x86/amd/hsmp: Change devm_kzalloc() to devm_kcalloc()

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

 



On Sat, 6 Jan 2024, Suma Hegde wrote:

> Use the standard array allocation variant of devm memory allocation
> APIs.
> 
> Signed-off-by: Suma Hegde <suma.hegde@xxxxxxx>
> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@xxxxxxx>
> ---
> Changes since v4:
> 1. Change sizeof(struct bin_attribute *) to sizeof(*hsmp_bin_attrs)
> 2. Change sizeof(struct attribute_group *) to sizeof(*hsmp_attr_grps)
> 3. Split some of the changes to 11th patch in this v5 series
> 
> Changes since v3:
> New patch, based on Ilpos review comments and additional cosmetic changes.
>  drivers/platform/x86/amd/hsmp.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp.c
> index 99bebb0ca5a9..ccf7cd8f98f6 100644
> --- a/drivers/platform/x86/amd/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp.c
> @@ -657,8 +657,9 @@ static int hsmp_create_attr_list(struct attribute_group *attr_grp,
>  	struct bin_attribute **hsmp_bin_attrs;
>  
>  	/* Null terminated list of attributes */
> -	hsmp_bin_attrs = devm_kzalloc(dev, sizeof(struct bin_attribute *) *
> -				      (NUM_HSMP_ATTRS + 1), GFP_KERNEL);
> +	hsmp_bin_attrs = devm_kcalloc(dev, NUM_HSMP_ATTRS + 1,
> +				      sizeof(*hsmp_bin_attrs),
> +				      GFP_KERNEL);
>  	if (!hsmp_bin_attrs)
>  		return -ENOMEM;
>  
> @@ -673,8 +674,9 @@ static int hsmp_create_non_acpi_sysfs_if(struct device *dev)
>  	struct attribute_group *attr_grp;
>  	u16 i;
>  
> -	hsmp_attr_grps = devm_kzalloc(dev, sizeof(struct attribute_group *) *
> -				      (plat_dev.num_sockets + 1), GFP_KERNEL);
> +	hsmp_attr_grps = devm_kcalloc(dev, plat_dev.num_sockets + 1,
> +				      sizeof(*hsmp_attr_grps),
> +				      GFP_KERNEL);
>  	if (!hsmp_attr_grps)
>  		return -ENOMEM;
>  
> @@ -804,8 +806,8 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev)
>  	 * on each probe.
>  	 */
>  	if (!plat_dev.is_probed) {
> -		plat_dev.sock = devm_kzalloc(&pdev->dev,
> -					     (plat_dev.num_sockets * sizeof(struct hsmp_socket)),
> +		plat_dev.sock = devm_kcalloc(&pdev->dev, plat_dev.num_sockets,
> +					     sizeof(struct hsmp_socket),

I wonder why the sizeof() of the target isn't used in this case like in 
the other cases?

-- 
 i.





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux