Skip to content

Commit

Permalink
l2tp: cleanup kzalloc calls
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tom Parkin authored and David S. Miller committed Jul 23, 2020
1 parent 0787840 commit 70c05bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/l2tp/l2tp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 70c05bf

Please sign in to comment.