[PATCH v2 10/12] w1: use pointers instead of types to determine size of allocs

From: Steffen Vogel
Date: Sun Oct 28 2018 - 23:12:27 EST


Get size of allocation based on pointer not type.

Signed-off-by: Steffen Vogel <post@xxxxxxxxxxxxxxx>
---
drivers/w1/w1.c | 2 +-
drivers/w1/w1_int.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 4cbe1849fbfc..87094d99ccbe 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -756,7 +756,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
int err;
struct w1_netlink_msg msg;

- sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL);
+ sl = kzalloc(sizeof(*sl), GFP_KERNEL);
if (!sl)
return -ENOMEM;

diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index a5230c0d49e3..2bf7631ac24f 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -31,7 +31,7 @@ static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
/*
* We are in process context(kernel thread), so can sleep.
*/
- dev = kzalloc(sizeof(struct w1_master) +
+ dev = kzalloc(sizeof(*dev) +
sizeof(struct w1_bus_master), GFP_KERNEL);
if (!dev)
return NULL;
--
2.11.0