gtp-rtnl: fix leak in struct mnl_socket on error in gtp_dev_create()
Release it in the error path.
This commit is contained in:
parent
e91a1a4ab7
commit
efdbb3bc73
|
@ -51,7 +51,7 @@ int gtp_dev_create(const char *ifname)
|
||||||
|
|
||||||
if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
|
if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
|
||||||
perror("mnl_socket_bind");
|
perror("mnl_socket_bind");
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
portid = mnl_socket_get_portid(nl);
|
portid = mnl_socket_get_portid(nl);
|
||||||
|
|
||||||
|
@ -60,23 +60,25 @@ int gtp_dev_create(const char *ifname)
|
||||||
|
|
||||||
if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
|
if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
|
||||||
perror("mnl_socket_send");
|
perror("mnl_socket_send");
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
|
ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
perror("read");
|
perror("read");
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL);
|
ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL);
|
||||||
if (ret == -1){
|
if (ret == -1){
|
||||||
perror("callback");
|
perror("callback");
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
mnl_socket_close(nl);
|
mnl_socket_close(nl);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
err:
|
||||||
|
mnl_socket_close(nl);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(gtp_dev_create);
|
EXPORT_SYMBOL(gtp_dev_create);
|
||||||
|
|
Loading…
Reference in New Issue