From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225vEwSoyUhWI24rOjU9HCZ+sxPa85Zz4tHMRBLqaMb29tjQC+Z6pH0WGQoY6ZxltyXIZjsc ARC-Seal: i=1; a=rsa-sha256; t=1517256809; cv=none; d=google.com; s=arc-20160816; b=FqyLA74LXBBpQWp8C3n1Bpm/l1RtTOO96Ye/rwb1D1/XvR+Hs5wJqzPPpbNjZtTTvL FnHY00aQ0jNi8WKIQ6JXD8FTmPIBCxD5B4Xl0jvv0Eg0HNLIK9MWOX++0dz0655BssiI GgfdVjLBRjCKMKrFy5clRMPg3bzjVpkehtcey0Tzc/VLQmnJDmZNrX+zTVghqupDpwjV iLbDFk9td3TmMZPoWH2Yib1/5Uhz919+Wke45jDL/ObY0bj5jsXHZiVOjohxwbt1i87f 2viC4d7GFsvaEtj1u1jsNk5XW8NIZW75KnUDofke3s1TW3vhRNs0o+djaSjMaFHzOwSt Qh9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=askvPr3NSKNA79/huHkclIo4q9bBRrP+JLPmRCCtMZE=; b=R6mgvy3LA7604OxQwjq5Oy+mJJXhR0rPaTEwkJl1XKoeuC68OaooITImI26G0gAey9 4xa3l1022j0PsFdPf5QelteVcGcxArnfx6sCtwbps0RYSjyvF5/Vv4W+b3CiTmuRptXZ MeW5jpmwvkGVqqKPxNflvt3M6qzGhDnLvtRE0ZGTeoxbYX3xLw0uKAltwUnDVMrHG5UM 3tAWkq8efoiJbGhH/6DQFltjZiM+pWxPtC9BqjQXNw2EQNv3myR33mzSGTtgDfwdBWYE gj6jl/kRXf8KOocIJW61fFaArA4YSDAALjF7QDM77fDehJP0rA2KavtOwnVbdit3BcOR sA4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , Jon Maloy , Ying Xue , Cong Wang , "David S. Miller" Subject: [PATCH 4.9 45/66] tipc: fix a memory leak in tipc_nl_node_get_link() Date: Mon, 29 Jan 2018 13:57:09 +0100 Message-Id: <20180129123842.270480910@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958639065786004?= X-GMAIL-MSGID: =?utf-8?q?1590959076247267732?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit 59b36613e85fb16ebf9feaf914570879cd5c2a21 ] When tipc_node_find_by_name() fails, the nlmsg is not freed. While on it, switch to a goto label to properly free it. Fixes: be9c086715c ("tipc: narrow down exposure of struct tipc_node") Reported-by: Dmitry Vyukov Cc: Jon Maloy Cc: Ying Xue Signed-off-by: Cong Wang Acked-by: Ying Xue Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/node.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -1848,36 +1848,38 @@ int tipc_nl_node_get_link(struct sk_buff if (strcmp(name, tipc_bclink_name) == 0) { err = tipc_nl_add_bc_link(net, &msg); - if (err) { - nlmsg_free(msg.skb); - return err; - } + if (err) + goto err_free; } else { int bearer_id; struct tipc_node *node; struct tipc_link *link; node = tipc_node_find_by_name(net, name, &bearer_id); - if (!node) - return -EINVAL; + if (!node) { + err = -EINVAL; + goto err_free; + } tipc_node_read_lock(node); link = node->links[bearer_id].link; if (!link) { tipc_node_read_unlock(node); - nlmsg_free(msg.skb); - return -EINVAL; + err = -EINVAL; + goto err_free; } err = __tipc_nl_add_link(net, &msg, link, 0); tipc_node_read_unlock(node); - if (err) { - nlmsg_free(msg.skb); - return err; - } + if (err) + goto err_free; } return genlmsg_reply(msg.skb, info); + +err_free: + nlmsg_free(msg.skb); + return err; } int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info)