[PATCH] Guard against a potential NULL pointer dereference in old_capi_manufacturer()

Previous thread: Re: [AppArmor 39/45] AppArmor: Profile loading and manipulation, pathname matching by David Wagner on Sunday, June 24, 2007 - 2:45 pm. (2 messages)

Next thread: Re: [patch 1/3] add the fsblock layer by Neil Brown on Sunday, June 24, 2007 - 4:01 pm. (5 messages)
From: Jesper Juhl
Date: Sunday, June 24, 2007 - 3:34 pm

In drivers/isdn/capi/kcapi.c::old_capi_manufacturer(), if the call 
to get_capi_ctr_by_nr(ldef.contr); in line 823 returns NULL, then 
we'll be dereferencing a NULL pointer in the very next line.

(Found by Coverity checker as bug #402)


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 drivers/isdn/capi/kcapi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 3ed34f7..3f9e962 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -821,6 +821,8 @@ static int old_capi_manufacturer(unsigned int cmd, void 
__user *data)
 				return -EFAULT;
 		}
 		card = get_capi_ctr_by_nr(ldef.contr);
+		if (!card)
+			return -EINVAL;
 		card = capi_ctr_get(card);
 		if (!card)
 			return -ESRCH;
-

Previous thread: Re: [AppArmor 39/45] AppArmor: Profile loading and manipulation, pathname matching by David Wagner on Sunday, June 24, 2007 - 2:45 pm. (2 messages)

Next thread: Re: [patch 1/3] add the fsblock layer by Neil Brown on Sunday, June 24, 2007 - 4:01 pm. (5 messages)