Patchwork sctp: kzalloc() error handling on deleting last address

login
register
mail settings
Submitter Michio Honda
Date June 10, 2011, 8:07 a.m.
Message ID <F8A1B797-89A2-4AAA-AFB1-9B187AC08456@sfc.wide.ad.jp>
Download mbox | patch
Permalink /patch/99855/
State Superseded
Delegated to: David Miller
Headers show

Comments

Michio Honda - June 10, 2011, 8:07 a.m.
From 49a66ecad72af8c367b125c695a113d3f3870320 Mon Sep 17 00:00:00 2001
From: Michio Honda <micchie@sfc.wide.ad.jp>
Date: Fri, 10 Jun 2011 16:42:14 +0900
Subject: [PATCH] sctp: kzalloc() error handling on deleting last address

Signed-off-by: Michio Honda <micchie@sfc.wide.ad.jp>
---
 net/sctp/socket.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Wei Yongjun - June 10, 2011, 8:21 a.m.
> From 49a66ecad72af8c367b125c695a113d3f3870320 Mon Sep 17 00:00:00 2001
> From: Michio Honda <micchie@sfc.wide.ad.jp>
> Date: Fri, 10 Jun 2011 16:42:14 +0900
> Subject: [PATCH] sctp: kzalloc() error handling on deleting last address
>
> Signed-off-by: Michio Honda <micchie@sfc.wide.ad.jp>
> ---
>  net/sctp/socket.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index e7e1b14..a23d898 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -786,6 +786,8 @@ static int sctp_send_asconf_del_ip(struct sock		*sk,
>  				continue;
>  			asoc->asconf_addr_del_pending =
>  			    kzalloc(sizeof(union sctp_addr), GFP_ATOMIC);
> +			if (asoc->asconf_addr_del_pending == NULL) 
> +				continue;

better to return with ENOMEM.

if (asoc->asconf_addr_del_pending == NULL) {
	retval = -ENOMEM;
	goto out;
}


>  			asoc->asconf_addr_del_pending->sa.sa_family =
>  				    addrs->sa_family;
>  			asoc->asconf_addr_del_pending->v4.sin_port =
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index e7e1b14..a23d898 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -786,6 +786,8 @@  static int sctp_send_asconf_del_ip(struct sock		*sk,
 				continue;
 			asoc->asconf_addr_del_pending =
 			    kzalloc(sizeof(union sctp_addr), GFP_ATOMIC);
+			if (asoc->asconf_addr_del_pending == NULL) 
+				continue;
 			asoc->asconf_addr_del_pending->sa.sa_family =
 				    addrs->sa_family;
 			asoc->asconf_addr_del_pending->v4.sin_port =