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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <A874F61F95741C4A9BA573A70FE3998F41EF1C73@DQHE02.ent.ti.com>
Date:	Thu, 30 Aug 2012 11:37:34 +0000
From:	"Kim, Milo" <Milo.Kim@...com>
To:	Anton Vorontsov <cbouatmailru@...il.com>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	David Woodhouse <dwmw2@...radead.org>,
	Anton Vorontsov <anton.vorontsov@...aro.org>
Subject: [PATCH 1/8] lp8727_charger: use devm_kzalloc() rather than
 kzalloc()/kfree()

make allocating/freeing the private data simpler

Signed-off-by: Milo(Woogyom) Kim <milo.kim@...com>
---
 drivers/power/lp8727_charger.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c
index 4e37b26..fb3d7ac 100644
--- a/drivers/power/lp8727_charger.c
+++ b/drivers/power/lp8727_charger.c
@@ -360,7 +360,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
 {
 	struct lp8727_psy *psy;
 
-	psy = kzalloc(sizeof(*psy), GFP_KERNEL);
+	psy = devm_kzalloc(pchg->dev, sizeof(*psy), GFP_KERNEL);
 	if (!psy)
 		return -ENOMEM;
 
@@ -405,7 +405,6 @@ err_psy_batt:
 err_psy_usb:
 	power_supply_unregister(&psy->ac);
 err_psy_ac:
-	kfree(psy);
 	return -EPERM;
 }
 
@@ -419,7 +418,6 @@ static void lp8727_unregister_psy(struct lp8727_chg *pchg)
 	power_supply_unregister(&psy->ac);
 	power_supply_unregister(&psy->usb);
 	power_supply_unregister(&psy->batt);
-	kfree(psy);
 }
 
 static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
@@ -430,7 +428,7 @@ static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
 	if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
 		return -EIO;
 
-	pchg = kzalloc(sizeof(*pchg), GFP_KERNEL);
+	pchg = devm_kzalloc(&cl->dev, sizeof(*pchg), GFP_KERNEL);
 	if (!pchg)
 		return -ENOMEM;
 
@@ -462,7 +460,6 @@ static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
 	return 0;
 
 error:
-	kfree(pchg);
 	return ret;
 }
 
@@ -474,7 +471,6 @@ static int __devexit lp8727_remove(struct i2c_client *cl)
 	free_irq(pchg->client->irq, pchg);
 	flush_workqueue(pchg->irqthread);
 	destroy_workqueue(pchg->irqthread);
-	kfree(pchg);
 	return 0;
 }
 
-- 
1.7.9.5


Best Regards,
Milo


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ