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-next>] [day] [month] [year] [list]
Message-Id: <20240910072642.39396-1-zhangjiao2@cmss.chinamobile.com>
Date: Tue, 10 Sep 2024 15:26:42 +0800
From: zhangjiao2 <zhangjiao2@...s.chinamobile.com>
To: rui.silva@...aro.org
Cc: gregkh@...uxfoundation.org,
	linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	zhang jiao <zhangjiao2@...s.chinamobile.com>
Subject: [PATCH] usb: isp1760: Use devm_kcalloc

From: zhang jiao <zhangjiao2@...s.chinamobile.com>

Use devm_kcalloc to simplify code.

Signed-off-by: zhang jiao <zhangjiao2@...s.chinamobile.com>
---
 drivers/usb/isp1760/isp1760-hcd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index 0e5e4cb74c87..593ce841ae53 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -2572,18 +2572,18 @@ int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
 
 	priv->hcd = hcd;
 
-	priv->atl_slots = kcalloc(mem_layout->slot_num,
+	priv->atl_slots = devm_kcalloc(dev, mem_layout->slot_num,
 				  sizeof(struct isp1760_slotinfo), GFP_KERNEL);
 	if (!priv->atl_slots) {
 		ret = -ENOMEM;
 		goto put_hcd;
 	}
 
-	priv->int_slots = kcalloc(mem_layout->slot_num,
+	priv->int_slots = devm_kcalloc(dev, mem_layout->slot_num,
 				  sizeof(struct isp1760_slotinfo), GFP_KERNEL);
 	if (!priv->int_slots) {
 		ret = -ENOMEM;
-		goto free_atl_slots;
+		goto put_hcd;
 	}
 
 	init_memory(priv);
@@ -2597,16 +2597,12 @@ int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
 
 	ret = usb_add_hcd(hcd, irq, irqflags);
 	if (ret)
-		goto free_int_slots;
+		goto put_hcd;
 
 	device_wakeup_enable(hcd->self.controller);
 
 	return 0;
 
-free_int_slots:
-	kfree(priv->int_slots);
-free_atl_slots:
-	kfree(priv->atl_slots);
 put_hcd:
 	usb_put_hcd(hcd);
 	return ret;
@@ -2619,6 +2615,4 @@ void isp1760_hcd_unregister(struct isp1760_hcd *priv)
 
 	usb_remove_hcd(priv->hcd);
 	usb_put_hcd(priv->hcd);
-	kfree(priv->atl_slots);
-	kfree(priv->int_slots);
 }
-- 
2.33.0




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ