Skip to content

Commit 7f8436a

Browse files
Wei Yongjundavem330
authored andcommitted
l2tp: fix return value check
In case of error, the function genlmsg_put() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 392b408 commit 7f8436a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

net/l2tp/l2tp_netlink.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ static int l2tp_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
8080

8181
hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq,
8282
&l2tp_nl_family, 0, L2TP_CMD_NOOP);
83-
if (IS_ERR(hdr)) {
84-
ret = PTR_ERR(hdr);
83+
if (!hdr) {
84+
ret = -EMSGSIZE;
8585
goto err_out;
8686
}
8787

@@ -250,8 +250,8 @@ static int l2tp_nl_tunnel_send(struct sk_buff *skb, u32 pid, u32 seq, int flags,
250250

251251
hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags,
252252
L2TP_CMD_TUNNEL_GET);
253-
if (IS_ERR(hdr))
254-
return PTR_ERR(hdr);
253+
if (!hdr)
254+
return -EMSGSIZE;
255255

256256
if (nla_put_u8(skb, L2TP_ATTR_PROTO_VERSION, tunnel->version) ||
257257
nla_put_u32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id) ||
@@ -617,8 +617,8 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 pid, u32 seq, int flags
617617
sk = tunnel->sock;
618618

619619
hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags, L2TP_CMD_SESSION_GET);
620-
if (IS_ERR(hdr))
621-
return PTR_ERR(hdr);
620+
if (!hdr)
621+
return -EMSGSIZE;
622622

623623
if (nla_put_u32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id) ||
624624
nla_put_u32(skb, L2TP_ATTR_SESSION_ID, session->session_id) ||

0 commit comments

Comments
 (0)