[openib-general] [PATCH] mthca: fix mem leaks in mthca_provider error handling

Jack Morgenstein jackm at mellanox.co.il
Thu Jan 12 06:23:59 PST 2006


Fixes memory leaks in mthca_create_qp and mthca_create_srq error handling.

Signed-off-by: Jack Morgenstein <jackm at mellanox.co.il>

Index: gen2/drivers/infiniband/hw/mthca/mthca_provider.c
===================================================================
--- gen2.orig/drivers/infiniband/hw/mthca/mthca_provider.c	2006-01-12 15:21:24.935512000 +0200
+++ gen2/drivers/infiniband/hw/mthca/mthca_provider.c	2006-01-12 15:23:06.839657000 +0200
@@ -463,8 +463,10 @@ static struct ib_srq *mthca_create_srq(s
 	if (pd->uobject) {
 		context = to_mucontext(pd->uobject->context);
 
-		if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
-			return ERR_PTR(-EFAULT);
+		if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+			err = -EFAULT;
+			goto err_free;
+		}
 
 		err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
 					context->db_tab, ucmd.db_index,
@@ -540,8 +542,10 @@ static struct ib_qp *mthca_create_qp(str
 		if (pd->uobject) {
 			context = to_mucontext(pd->uobject->context);
 
-			if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
+			if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+				kfree(qp);
 				return ERR_PTR(-EFAULT);
+			}
 
 			err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
 						context->db_tab,



More information about the general mailing list