netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Buslov <vladbu@mellanox.com>
To: netdev@vger.kernel.org, dcaratti@redhat.com
Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	davem@davemloft.net, wenxu@ucloud.cn, roid@mellanox.com,
	Vlad Buslov <vladbu@mellanox.com>
Subject: [PATCH net] net: sched: act_tunnel_key: fix NULL pointer dereference during init
Date: Mon, 25 Feb 2019 17:28:27 +0200	[thread overview]
Message-ID: <20190225152827.8741-1-vladbu@mellanox.com> (raw)
In-Reply-To: <4bde1d403d4ba9b51cf18bbaac1d46147011b959.camel@redhat.com>

Metadata pointer is only initialized for action TCA_TUNNEL_KEY_ACT_SET, but
it is unconditionally dereferenced in tunnel_key_init() error handler.
Verify that metadata pointer is not NULL before dereferencing it in
tunnel_key_init error handling code.

Fixes: ee28bb56ac5b ("net/sched: fix memory leak in act_tunnel_key_init()")
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 net/sched/act_tunnel_key.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
index 8b43fe0130f7..3f943de9a2c9 100644
--- a/net/sched/act_tunnel_key.c
+++ b/net/sched/act_tunnel_key.c
@@ -377,7 +377,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
 	return ret;
 
 release_tun_meta:
-	dst_release(&metadata->dst);
+	if (metadata)
+		dst_release(&metadata->dst);
 
 err_out:
 	if (exists)
-- 
2.13.6


  parent reply	other threads:[~2019-02-25 15:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 12:21 [PATCH net-next] net: sched: act_tunnel_key: fix metadata handling Vlad Buslov
2019-02-25 14:04 ` Davide Caratti
2019-02-25 15:12   ` Vlad Buslov
2019-02-25 15:28   ` Vlad Buslov [this message]
2019-02-25 15:36     ` [PATCH net] net: sched: act_tunnel_key: fix NULL pointer dereference during init Davide Caratti
2019-02-25 18:16     ` David Miller
2019-02-25 15:30   ` [PATCH net-next v2] net: sched: act_tunnel_key: fix metadata handling Vlad Buslov
2019-02-27  8:14     ` Roi Dayan
2019-02-28  5:36     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190225152827.8741-1-vladbu@mellanox.com \
    --to=vladbu@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=roid@mellanox.com \
    --cc=wenxu@ucloud.cn \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).