__nc_error() does not check return value from malloc
diff mbox

Message ID 1384966173-6229-2-git-send-email-ssahani@redhat.com
State New, archived
Headers show

Commit Message

Susant Sahani Nov. 20, 2013, 4:49 p.m. UTC
Signed-off-by: Susant Sahani <ssahani@redhat.com>
---
 src/getnetconfig.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steve Dickson Nov. 25, 2013, 8:09 p.m. UTC | #1
On 20/11/13 11:49, Susant Sahani wrote:
> Signed-off-by: Susant Sahani <ssahani@redhat.com>
Committed.... 

steved.

> ---
>  src/getnetconfig.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/getnetconfig.c b/src/getnetconfig.c
> index af4a484..2460a6e 100644
> --- a/src/getnetconfig.c
> +++ b/src/getnetconfig.c
> @@ -146,7 +146,8 @@ __nc_error()
>  			return (&nc_error);
>  	}
>  	if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) {
> -		nc_addr = (int *)malloc(sizeof (int));
> +		if((nc_addr = (int *)malloc(sizeof (int))) == NULL)
> +			return (&nc_error);
>  		if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
>  			if (nc_addr)
>  				free(nc_addr);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/src/getnetconfig.c b/src/getnetconfig.c
index af4a484..2460a6e 100644
--- a/src/getnetconfig.c
+++ b/src/getnetconfig.c
@@ -146,7 +146,8 @@  __nc_error()
 			return (&nc_error);
 	}
 	if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) {
-		nc_addr = (int *)malloc(sizeof (int));
+		if((nc_addr = (int *)malloc(sizeof (int))) == NULL)
+			return (&nc_error);
 		if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
 			if (nc_addr)
 				free(nc_addr);