linux-x25.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: linzhang <xiaolou4617@gmail.com>
To: andrew.hendry@gmail.com, davem@davemloft.net
Cc: nhorman@tuxdriver.com, linux-x25@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linzhang <xiaolou4617@gmail.com>
Subject: [PATCH] net: x25: fix one potential use-after-free issue
Date: Mon, 15 May 2017 12:12:49 +0800	[thread overview]
Message-ID: <1494821569-18572-1-git-send-email-xiaolou4617@gmail.com> (raw)

The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add right unregister call on error handler.

Signed-off-by: linzhang <xiaolou4617@gmail.com>
---
 net/x25/af_x25.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..e01e09a 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1811,12 +1811,14 @@ static int __init x25_init(void)
 	x25_register_sysctl();
 	rc = x25_proc_init();
 	if (rc != 0)
-		goto out_dev;
+		goto out_sysctl;
 out:
 	return rc;
-out_dev:
+out_sysctl:
+	x25_unregister_sysctl();
 	unregister_netdevice_notifier(&x25_dev_notifier);
 out_sock:
+	dev_remove_pack(&x25_packet_type);
 	sock_unregister(AF_X25);
 out_proto:
 	proto_unregister(&x25_proto);
-- 
1.8.3.1


             reply	other threads:[~2017-05-15  4:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15  4:12 linzhang [this message]
2017-05-15 18:47 ` [PATCH] net: x25: fix one potential use-after-free issue 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=1494821569-18572-1-git-send-email-xiaolou4617@gmail.com \
    --to=xiaolou4617@gmail.com \
    --cc=andrew.hendry@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-x25@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.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 read-only IMAP folder(s) and NNTP newsgroup(s).