Re: [PATCH] usb: typec: qcom-pmic-typec: use kcalloc() instead of kzalloc()

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

 



On Tue, Aug 19, 2025 at 05:01:24PM +0800, Qianfeng Rong wrote:
> Replace devm_kzalloc() with devm_kcalloc() in qcom_pmic_typec_pdphy_probe()
> and qcom_pmic_typec_port_probe() for safer memory allocation with built-in
> overflow protection.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@xxxxxxxx>

Reviewed-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>

> ---
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 18303b34594b..c8b1463e6e8b 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -567,7 +567,7 @@ int qcom_pmic_typec_pdphy_probe(struct platform_device *pdev,
>  	if (!res->nr_irqs || res->nr_irqs > PMIC_PDPHY_MAX_IRQS)
>  		return -EINVAL;
>  
> -	irq_data = devm_kzalloc(dev, sizeof(*irq_data) * res->nr_irqs,
> +	irq_data = devm_kcalloc(dev, res->nr_irqs, sizeof(*irq_data),
>  				GFP_KERNEL);
>  	if (!irq_data)
>  		return -ENOMEM;
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> index 4fc83dcfae64..8051eaa46991 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> @@ -713,7 +713,7 @@ int qcom_pmic_typec_port_probe(struct platform_device *pdev,
>  	if (!res->nr_irqs || res->nr_irqs > PMIC_TYPEC_MAX_IRQS)
>  		return -EINVAL;
>  
> -	irq_data = devm_kzalloc(dev, sizeof(*irq_data) * res->nr_irqs,
> +	irq_data = devm_kcalloc(dev, res->nr_irqs, sizeof(*irq_data),
>  				GFP_KERNEL);
>  	if (!irq_data)
>  		return -ENOMEM;
> -- 
> 2.34.1

-- 
heikki




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux