From patchwork Thu Nov 23 14:04:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17156 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 013DF80736; Thu, 23 Nov 2017 15:05:46 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=openmesh-com.20150623.gappssmtp.com header.i=@openmesh-com.20150623.gappssmtp.com header.b="LyHZJ+D0"; dkim-atps=neutral Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:400d:c0d::242; helo=mail-qt0-x242.google.com; envelope-from=sven.eckelmann@openmesh.com; receiver= Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) by open-mesh.org (Postfix) with ESMTPS id 13E1B8060C for ; Thu, 23 Nov 2017 15:05:22 +0100 (CET) Received: by mail-qt0-x242.google.com with SMTP id r58so28092846qtc.0 for ; Thu, 23 Nov 2017 06:05:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openmesh-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W7uISMSB4oZxgyIxqzAhpNHH4aC7d1v/LhlY7Far7is=; b=LyHZJ+D0f4h89EtXuDW/wG0nR8XCXTTsvDofHpHUcuAI5SSk8UZsf4aZTjTsdwGdBs CnPx2sTJzoauFVC8+CtQny2md95ELNm5Gowp+8v+nRvi6NhlwsxT5MHDJx7lBN6lI7YH fE7tKKY3KeRUkJBiT4H3OLcOsC0+9fiXI8lArihJh3L8WLGkrzGGLV1rxGolviCq/rjj juq5Nzet5cTMgaWG3Zu5la91CGmpCw1SjHwZgyXIvcD8LTQNKE5/Id98DdN1RqG+28I1 it1MFME9xIDgZmQbe+ss+vLMTNhIULGOh2DJmldCCkPnByUu6CCiqGOe4iMg+RgrKDDV 6mVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W7uISMSB4oZxgyIxqzAhpNHH4aC7d1v/LhlY7Far7is=; b=pdrg9yAYyJ3O5WH22Um2N0aFmMsflENQmCXEKvatk1MPF8Voeo772ajCo5MJo9fqyH LxkhgPj1TolZAr9zim/DQVcDzT4qBsIIMztvFu7OmNHh3UvIZY6t/9YBOYTLDV2g43+E Sat4SYwA8N9ic0PXdjmmCShELMGegaq29Y1rM25+dPtxM4ahMlnfb3ldlMxtlpgCOBGu 2Ze8V00Hc1m7VpG/NMiOiTc7T4Zwadu/jImUT8Nw/2U4OCbu5kjDVzH1cn4DdVq1HUwl tRoJrPVNbOgLpgOhTUbneM8+sLjtX5bwEHEuEwkjl99FYxWPMuxVWIzqOT4l/uAKWskc gESA== X-Gm-Message-State: AJaThX6ZLiffLriouKJazH5CbyLLehF5BzPqN0XY0XTDY7soUuTsDIPE YUHfE0m26/oM++/zCS1jhhwzbd7V X-Google-Smtp-Source: AGs4zManCkqpV/do5pwdOsEDfNRw3gG4UerMKjfTzbmYUB4TUC/sCOhVTwh06oiUC7rHm2buukjQUg== X-Received: by 10.237.35.246 with SMTP id k51mr38949877qtc.163.1511445919442; Thu, 23 Nov 2017 06:05:19 -0800 (PST) Received: from sven-desktop.home.narfation.org (p2003007C6F53F7FA6FAE965552C91071.dip0.t-ipconnect.de. [2003:7c:6f53:f7fa:6fae:9655:52c9:1071]) by smtp.gmail.com with ESMTPSA id y58sm13104568qtb.9.2017.11.23.06.05.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Nov 2017 06:05:19 -0800 (PST) From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 23 Nov 2017 15:04:39 +0100 Message-Id: <20171123140444.17119-6-sven.eckelmann@openmesh.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123140444.17119-1-sven.eckelmann@openmesh.com> References: <20171123140444.17119-1-sven.eckelmann@openmesh.com> Subject: [B.A.T.M.A.N.] [PATCH 05/10] batctl: Handle nl_socket_alloc errors X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: Sven Eckelmann Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" nl_socket_alloc may return NULL on errors. The processing has to be aborted when this happens. Fixes: d8dd1ff1a0fe ("batctl: Use netlink to replace some of debugfs") Signed-off-by: Sven Eckelmann --- netlink.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/netlink.c b/netlink.c index e3d7892..d7aeb9a 100644 --- a/netlink.c +++ b/netlink.c @@ -295,6 +295,9 @@ static char *netlink_get_info(int ifindex, uint8_t nl_cmd, const char *header) }; sock = nl_socket_alloc(); + if (!sock) + return NULL; + genl_connect(sock); family = genl_ctrl_resolve(sock, BATADV_NL_NAME); @@ -397,6 +400,9 @@ int netlink_print_routing_algos(void) }; sock = nl_socket_alloc(); + if (!sock) + return -ENOMEM; + genl_connect(sock); family = genl_ctrl_resolve(sock, BATADV_NL_NAME); @@ -1104,6 +1110,9 @@ static int netlink_print_common(char *mesh_iface, char *orig_iface, int family; sock = nl_socket_alloc(); + if (!sock) + return -ENOMEM; + genl_connect(sock); family = genl_ctrl_resolve(sock, BATADV_NL_NAME);