[PATCH][PPP] ppp_generic: Add checks for NULL pointers

From: Hmamouche, Youssef
Date: Thu Aug 04 2005 - 01:21:15 EST



This patch adds two checks for NULL pointers.

Signed-off-by: Youssef Hmamouche <hyoussef@xxxxxxxxx>



--- a/drivers/net/ppp_generic.c 2005-07-15 14:18:57.000000000 -0700
+++ b/drivers/net/ppp_generic.c 2005-08-03 21:11:14.000000000 -0700
@@ -2644,6 +2644,11 @@
do {
/* need a new top level */
struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
+ if(np == NULL) {
+ printk(KERN_ERR "ppp_generic: Couldn't allocate "
+ "memory for cardmap.\n");
+ continue;
+ }
memset(np, 0, sizeof(*np));
np->ptr[0] = p;
if (p != NULL) {
@@ -2659,6 +2664,11 @@
i = (nr >> p->shift) & CARDMAP_MASK;
if (p->ptr[i] == NULL) {
struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
+ if(np == NULL) {
+ printk(KERN_ERR "ppp_generic: Couldn't allocate "
+ "memory for cardmap.\n");
+ continue;
+ }
memset(np, 0, sizeof(*np));
np->shift = p->shift - CARDMAP_ORDER;
np->parent = p;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/