All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Cusack <fcusack@fcusack.com>
To: linux-kernel@vger.kernel.org, ppp@samba.org
Subject: [PATCH] 2.4.20/2.5.69 ppp_generic kmalloc()!=NULL check
Date: Mon, 12 May 2003 04:36:18 -0700	[thread overview]
Message-ID: <20030512043618.B29781@google.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 94 bytes --]

In ppp_generic.c:cardmap_set(), the return value from 2 kmalloc() calls
are not checked.

/fc

[-- Attachment #2: cardmap_set.patch --]
[-- Type: text/plain, Size: 1294 bytes --]

--- linux-2.4.20/drivers/net/ppp_generic.c.orig	Fri Apr 25 02:02:14 2003
+++ linux-2.4.20/drivers/net/ppp_generic.c	Fri Apr 25 02:21:36 2003
@@ -2270,17 +2270,20 @@ ppp_create_interface(int unit, int *retp
 	dev->priv = ppp;
 	dev->features |= NETIF_F_DYNALLOC;
 
+	if (ret = cardmap_set(&all_ppp_units, unit, ppp))
+		goto err_unlock;
+
 	rtnl_lock();
 	ret = register_netdevice(dev);
 	rtnl_unlock();
 	if (ret != 0) {
 		printk(KERN_ERR "PPP: couldn't register device %s (%d)\n",
 		       dev->name, ret);
+		cardmap_set(&all_ppp_units, unit, NULL))
 		goto err_unlock;
 	}
 
 	atomic_inc(&ppp_unit_count);
-	cardmap_set(&all_ppp_units, unit, ppp);
 	up(&all_ppp_sem);
 	*retp = 0;
 	return ppp;
@@ -2542,6 +2545,8 @@ static void cardmap_set(struct cardmap *
 		do {
 			/* need a new top level */
 			struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
+			if (np == 0)
+				return -ENOMEM;
 			memset(np, 0, sizeof(*np));
 			np->ptr[0] = p;
 			if (p != NULL) {
@@ -2557,6 +2562,8 @@ static void cardmap_set(struct cardmap *
 		i = (nr >> p->shift) & CARDMAP_MASK;
 		if (p->ptr[i] == NULL) {
 			struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
+			if (np == 0)
+				return -ENOMEM;
 			memset(np, 0, sizeof(*np));
 			np->shift = p->shift - CARDMAP_ORDER;
 			np->parent = p;

                 reply	other threads:[~2003-05-12 11:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030512043618.B29781@google.com \
    --to=fcusack@fcusack.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ppp@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.