Skip to content

Commit 1aaf6a7

Browse files
author
Al Viro
committed
do_mq_notify(): saner skb freeing on failures
cleanup is convoluted enough as it is; it's easier to have early failure outs do explicit kfree_skb(nc), rather than going to contortions needed to reuse the cleanup from late failures. Signed-off-by: Al Viro <[email protected]>
1 parent f302edb commit 1aaf6a7

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

ipc/mqueue.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,8 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
13471347
if (copy_from_user(nc->data,
13481348
notification->sigev_value.sival_ptr,
13491349
NOTIFY_COOKIE_LEN)) {
1350-
ret = -EFAULT;
1351-
goto free_skb;
1350+
kfree_skb(nc);
1351+
return -EFAULT;
13521352
}
13531353

13541354
/* TODO: add a header? */
@@ -1357,16 +1357,14 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
13571357
retry:
13581358
sock = netlink_getsockbyfd(notification->sigev_signo);
13591359
if (IS_ERR(sock)) {
1360-
ret = PTR_ERR(sock);
1361-
goto free_skb;
1360+
kfree_skb(nc);
1361+
return PTR_ERR(sock);
13621362
}
13631363

13641364
timeo = MAX_SCHEDULE_TIMEOUT;
13651365
ret = netlink_attachskb(sock, nc, &timeo, NULL);
1366-
if (ret == 1) {
1367-
sock = NULL;
1366+
if (ret == 1)
13681367
goto retry;
1369-
}
13701368
if (ret)
13711369
return ret;
13721370
}
@@ -1425,10 +1423,6 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
14251423
out:
14261424
if (sock)
14271425
netlink_detachskb(sock, nc);
1428-
else
1429-
free_skb:
1430-
dev_kfree_skb(nc);
1431-
14321426
return ret;
14331427
}
14341428

0 commit comments

Comments
 (0)