From patchwork Thu Nov 23 14:04:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17159 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 77CB3808DD; Thu, 23 Nov 2017 15:06:12 +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="wFBWoKg7"; 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 25CA9805EC for ; Thu, 23 Nov 2017 15:05:33 +0100 (CET) Received: by mail-qt0-x242.google.com with SMTP id a19so28041307qtb.3 for ; Thu, 23 Nov 2017 06:05:33 -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=G0mj60513jWw3YnjomHbC9W1Po/FTJHI6ltu500lTrw=; b=wFBWoKg7ydJEYwG69FLbDBCmRCbWPDjkaTv8ULqt/kNVVmndcVUR/gVJH7A2Jb+t4S CnNSwo8PArdsvXzs350vhm/3+uFGWh+IrFzMIkxwKQa2MEoQ/LKsscfeP3pW6Zlshclf MDGS9J3QJJYHQgehjUuF8/5ehTMCUAo9g5zUb1WAqSOEFrtnozAAnEgu9KRGVaMC+CV+ kFf1haXYiiB7GPEJInAxiCBoy9jcIUpRiL1wMkhSbeoB0WgTVpQ+Nup1dTngleUoth/M nJgDZwOXDpEj9q7wguI+OFXOMlY9Cs6aha8jHgbWXxfCbC3doaKSVcVekHOgvmUFVvn+ nHew== 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=G0mj60513jWw3YnjomHbC9W1Po/FTJHI6ltu500lTrw=; b=Cw5P2OxRsrWZvPj8BBEHZ8nIaCnty3JmE2myaXvLJG7qPcyH8sgpm/1Bc9/DZ1huQG mamH1VscamfynjlW7h4Pv8gdswUWRRbdXlkwdV5EGj5gGplAWxA25M3ITJk71J0Wy0Uz PxXH9jhIUZd5NyV+ijVVz99chKIeF3cFoD2enEcNRswnzQc93Q8zijM+Bj7e6L/WBKcK +d2wU/qralZFARPgNutxZqNyovWOMnar+j8FsKIUFFfrthQddTEVh/U6dfUp2zICf9Sk FwjKwOvAWVBl7ilSjauVOPPognwmvRZi6+nzvaca2RFx1A0pi4ArP1ghGAGiOOp7JM6O RBLA== X-Gm-Message-State: AJaThX4UVregCDffVhH6ytCtf6hyWyvQTRemJhL9g8Ck5qaHqDcO54ws MxvNzUp9zCbzHLpPOOWGhkPxGBg2 X-Google-Smtp-Source: AGs4zMZ0AczCXf3fftVyU3zI/kWD+3qF1TbYp4fZqcXtrasb9t2myuNa/OM0xDHpURbBk/P6CvJCsg== X-Received: by 10.200.4.154 with SMTP id s26mr40511629qtg.156.1511445930645; Thu, 23 Nov 2017 06:05:30 -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 y9sm8473309qti.63.2017.11.23.06.05.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Nov 2017 06:05:30 -0800 (PST) From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 23 Nov 2017 15:04:42 +0100 Message-Id: <20171123140444.17119-9-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 08/10] batctl: Free nl_sock when if_nametoindex failed 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" The if_nametoindex can return an error. The code must then free the previously allocated nl_sock and stop the function with an error code. Fixes: d8dd1ff1a0fe ("batctl: Use netlink to replace some of debugfs") Signed-off-by: Sven Eckelmann --- netlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netlink.c b/netlink.c index de81d08..7b97809 100644 --- a/netlink.c +++ b/netlink.c @@ -1137,7 +1137,8 @@ static int netlink_print_common(char *mesh_iface, char *orig_iface, ifindex = if_nametoindex(mesh_iface); if (!ifindex) { fprintf(stderr, "Interface %s is unknown\n", mesh_iface); - return -ENODEV; + last_err = -ENODEV; + goto err_free_sock; } if (orig_iface) { @@ -1145,7 +1146,8 @@ static int netlink_print_common(char *mesh_iface, char *orig_iface, if (!hardifindex) { fprintf(stderr, "Interface %s is unknown\n", orig_iface); - return -ENODEV; + last_err = -ENODEV; + goto err_free_sock; } }