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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 2 Nov 2017 09:00:28 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     kernel-janitors@...r.kernel.org,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>
Cc:     LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/3] regulator/core: Improve a size determination in four
 functions

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Wed, 1 Nov 2017 22:30:10 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/regulator/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 14fdf2f17a62..28859c186c9f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1223,7 +1223,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
 		return -EBUSY;
 	}
 
-	node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
+	node = kzalloc(sizeof(*node), GFP_KERNEL);
 	if (node == NULL)
 		return -ENOMEM;
 
@@ -1833,7 +1833,7 @@ int regulator_register_supply_alias(struct device *dev, const char *id,
 	if (map)
 		return -EEXIST;
 
-	map = kzalloc(sizeof(struct regulator_supply_alias), GFP_KERNEL);
+	map = kzalloc(sizeof(*map), GFP_KERNEL);
 	if (!map)
 		return -ENOMEM;
 
@@ -1964,7 +1964,7 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
 	if (ret)
 		return ret;
 
-	pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
+	pin = kzalloc(sizeof(*pin), GFP_KERNEL);
 	if (pin == NULL) {
 		gpio_free(config->ena_gpio);
 		return -ENOMEM;
@@ -4011,7 +4011,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
 		return ERR_PTR(-EINVAL);
 	}
 
-	rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL);
+	rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
 	if (rdev == NULL)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.14.3

Powered by blists - more mailing lists