Skip to content

Commit

Permalink
ax25: Fix possible oops in ax25_make_new
Browse files Browse the repository at this point in the history
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 <[email protected]>

Signed-off-by: Jarek Poplawski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jarek Poplawski authored and davem330 committed Sep 30, 2009
1 parent 81bbb3d commit 8c185ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)

sock_init_data(NULL, sk);

sk->sk_destruct = ax25_free_sock;
sk->sk_type = osk->sk_type;
sk->sk_priority = osk->sk_priority;
sk->sk_protocol = osk->sk_protocol;
Expand Down Expand Up @@ -939,6 +938,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
}

sk->sk_protinfo = ax25;
sk->sk_destruct = ax25_free_sock;
ax25->sk = sk;

return sk;
Expand Down

0 comments on commit 8c185ab

Please sign in to comment.