From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226Ox8QMarUFicKM7C/ofI8BUimhyiN8Uf0sIObvjU1AsccYtpbDQVTKTj3b0j3c5MJr+A1M ARC-Seal: i=1; a=rsa-sha256; t=1517256392; cv=none; d=google.com; s=arc-20160816; b=GjbRS7ZmL++uYV9QoyX8biQp++/Md/vBJoFT5khpoFqck8xjG1B6IqcOJlfDOWeCOB CraqzI4/w0C9k/HxdDauPDeAIqaaJHmanf0yJHXb/ipfziZeGCtYAsDX8Y2Fyx2YPxAN EZGV7T7gyvn2H7rICg9Hk8gzbww+AIUjfB6A1RKh8Oo7J/PUMJLSuS5hCL79n/kCvTMd 3W9uh6BaAvBKEMyjFkTzLWpe2Ys5AT7IZ7OHwSe7MjzmA1ZxAYISZTWre83f0d/0kTDN SKmgijad5ZNJKe1N7T37RfEkFsDtkN17/fAYNQhXHw4WP+L7IJ2yIGQ2DFkNfVk9QwGH vi4A== 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=zlEo8MBiMGogfh+oav8x3emjWnjw/r+YMuReXTlkUuI=; b=IROSNMrTb20avUptpQpj3iSTWvydGx3vXn8zhbpJwlUfihtj7umCz3PxGiJux7F+Io imdzc6FfuOVFE5tP6mOFikm85r7R7pSSfW0//KIRuXz1pG6CB79deCgPGLG6+ruBhhlH RiBAQTfBP2xA056LcvqSnx5gBCEk2KIYfMNkiH+C4BLu2YnRVo05CquQuuF+DUrI61Hq lq8TgGR35FUIOYeo02nw+OBkDX+ZluWp/gql4HwbYdUGbyIi7m9yoZGHw2TDpI0vftPp yW6+Rh3Ty3yXBo2qw/oUCoAOqzj76yeQdLr1HXg50chQCNfCGwkHCA232NEI1fyITk9+ 37DA== 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.14 39/71] tipc: fix a memory leak in tipc_nl_node_get_link() Date: Mon, 29 Jan 2018 13:57:07 +0100 Message-Id: <20180129123829.851028448@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@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?1590958639065786004?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-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)