Commit 84b17679 authored by Jarek Poplawski's avatar Jarek Poplawski Committed by Greg Kroah-Hartman

ax25: Fix possible oops in ax25_make_new

[ Upstream commit 8c185ab6 ]

In ax25_make_new, if kmemdup of digipeat returns an error, there would
be an oops in sk_free while calling sk_destruct, because sk_protinfo
is NULL at the moment; move sk->sk_destruct initialization after this.

BTW of reported-by: Bernard Pidoux F6BVP <f6bvp@free.fr>
Signed-off-by: default avatarJarek Poplawski <jarkao2@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fb0e8709
...@@ -893,7 +893,6 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev) ...@@ -893,7 +893,6 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
sock_init_data(NULL, sk); sock_init_data(NULL, sk);
sk->sk_destruct = ax25_free_sock;
sk->sk_type = osk->sk_type; sk->sk_type = osk->sk_type;
sk->sk_priority = osk->sk_priority; sk->sk_priority = osk->sk_priority;
sk->sk_protocol = osk->sk_protocol; sk->sk_protocol = osk->sk_protocol;
...@@ -931,6 +930,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev) ...@@ -931,6 +930,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
} }
sk->sk_protinfo = ax25; sk->sk_protinfo = ax25;
sk->sk_destruct = ax25_free_sock;
ax25->sk = sk; ax25->sk = sk;
return sk; return sk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment