1 From: Sven Eckelmann <sven.eckelmann@openmesh.com>
2 Date: Thu, 23 Nov 2017 15:04:40 +0100
3 Subject: [PATCH] batctl: Handle nl_cb_alloc errors
5 nl_cb_alloc may return NULL on errors. The processing has to be aborted
8 Fixes: d8dd1ff1a0fe ("batctl: Use netlink to replace some of debugfs")
9 Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
10 Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
12 Origin: upstream, https://git.open-mesh.org/batctl.git/commit/0a14f8800dac67d706827e9be7745e2319f5412c
14 netlink.c | 17 ++++++++++++++++-
15 1 file changed, 16 insertions(+), 1 deletion(-)
17 diff --git a/netlink.c b/netlink.c
18 index 107ca52a4866e25b7b04428d770a885ca4e826d2..3eb66c9de30c21722bb1e348b055838ea14d18cf 100644
21 @@ -320,11 +320,15 @@ static char *netlink_get_info(int ifindex, uint8_t nl_cmd, const char *header)
24 cb = nl_cb_alloc(NL_CB_DEFAULT);
28 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, info_callback, &opts);
29 nl_cb_err(cb, NL_CB_CUSTOM, print_error, NULL);
31 nl_recvmsgs(sock, cb);
36 return opts.remaining_header;
37 @@ -425,6 +429,11 @@ int netlink_print_routing_algos(void)
38 opts.remaining_header = strdup("Available routing algorithms:\n");
40 cb = nl_cb_alloc(NL_CB_DEFAULT);
46 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, netlink_print_common_cb,
48 nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, stop_callback, NULL);
49 @@ -1134,9 +1143,14 @@ static int netlink_print_common(char *mesh_iface, char *orig_iface,
53 + cb = nl_cb_alloc(NL_CB_DEFAULT);
59 bat_hosts_init(read_opt);
61 - cb = nl_cb_alloc(NL_CB_DEFAULT);
62 nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, netlink_print_common_cb, &opts);
63 nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, stop_callback, NULL);
64 nl_cb_err(cb, NL_CB_CUSTOM, print_error, NULL);
65 @@ -1181,6 +1195,7 @@ static int netlink_print_common(char *mesh_iface, char *orig_iface,