]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
l2tp: cleanup kzalloc calls
authorTom Parkin <tparkin@katalix.com>
Thu, 23 Jul 2020 11:29:55 +0000 (12:29 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Jul 2020 18:54:40 +0000 (11:54 -0700)
Passing "sizeof(struct blah)" in kzalloc calls is less readable,
potentially prone to future bugs if the type of the pointer is changed,
and triggers checkpatch warnings.

Tweak the kzalloc calls in l2tp which use this form to avoid the
warning.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/l2tp/l2tp_core.c

index d1403f27135ec0f09e4a50c0c18e1f11c977ac2c..7e3523015d6f35e06771e5a2e73cc864537d6e26 100644 (file)
@@ -1410,7 +1410,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
        if (cfg)
                encap = cfg->encap;
 
-       tunnel = kzalloc(sizeof(struct l2tp_tunnel), GFP_KERNEL);
+       tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL);
        if (!tunnel) {
                err = -ENOMEM;
                goto err;
@@ -1647,7 +1647,7 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
 {
        struct l2tp_session *session;
 
-       session = kzalloc(sizeof(struct l2tp_session) + priv_size, GFP_KERNEL);
+       session = kzalloc(sizeof(*session) + priv_size, GFP_KERNEL);
        if (session) {
                session->magic = L2TP_SESSION_MAGIC;
                session->tunnel = tunnel;