From patchwork Wed Sep 9 14:49:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 33179 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 60E29B7257 for ; Thu, 10 Sep 2009 00:44:00 +1000 (EST) Received: by ozlabs.org (Postfix) id 55DD8DDD0B; Thu, 10 Sep 2009 00:44:00 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (bilbo.ozlabs.org [203.10.76.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bilbo.ozlabs.org", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 53F1CDDD01 for ; Thu, 10 Sep 2009 00:44:00 +1000 (EST) Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4A50EB7E42 for ; Thu, 10 Sep 2009 00:43:46 +1000 (EST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 6AE87B70AD for ; Thu, 10 Sep 2009 00:43:39 +1000 (EST) Received: by ozlabs.org (Postfix) id 5C93FDDD0B; Thu, 10 Sep 2009 00:43:39 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.24]) by ozlabs.org (Postfix) with ESMTP id C58CEDDD01 for ; Thu, 10 Sep 2009 00:43:37 +1000 (EST) Received: by qw-out-2122.google.com with SMTP id 5so1049748qwi.15 for ; Wed, 09 Sep 2009 07:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=uDVEf53zlyiJK3juvNcSh2yMRdJzvpCnTjOHS8SGmCo=; b=BMsp3vMYbo/SXVBPK05sLRahO8JPKvwub37ujuyUr155WdJ/efz2tKLqQ2WbqYEAk5 /H3D8rq2ltwTCo9VWHcxsLgZrdBWPYrTPBCncBmlar5HaDkzGanIoCmDAGBCF/scT6tm XJTv+3/lWY7ShiLrGyXWTs9pm1HadcncD5vcg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=HNoDf6xP819ey86Eq1qgh8Tzy4/gckWZ+X1Ax0Zed1HapTcrWrn3BBc1OpcClgFW5B Q7YuxtfSSn/ozmTgiNGkZglTCseFSFx/rV5bF6CnffFQfJ3LY0YbGA1b4tIGQoXk8ft6 PxLRRF4bmUIMEds0CxB0DQHvRSjleN9tZiEos= Received: by 10.224.105.234 with SMTP id u42mr225782qao.161.1252507415794; Wed, 09 Sep 2009 07:43:35 -0700 (PDT) Received: from zoinx.mars (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id 4sm42178qwe.5.2009.09.09.07.43.33 (version=SSLv3 cipher=RC4-MD5); Wed, 09 Sep 2009 07:43:34 -0700 (PDT) Message-ID: <4AA7C095.7090009@gmail.com> Date: Wed, 09 Sep 2009 16:49:57 +0200 From: Roel Kluin User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3 MIME-Version: 1.0 To: benh@kernel.crashing.org, paulus@samba.org, linuxppc-dev@ozlabs.org, Andrew Morton Subject: [PATCH] 82xx: kmalloc failure ignored in ep8248e_mdio_probe() X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Prevent NULL dereference if kmalloc() fails. Also clean up if of_mdiobus_register() returns an error. Signed-off-by: Roel Kluin Acked-by: Scott Wood --- Found with sed: http://kernelnewbies.org/roelkluin Please review. diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c index 51fcae4..f9aee18 100644 --- a/arch/powerpc/platforms/82xx/ep8248e.c +++ b/arch/powerpc/platforms/82xx/ep8248e.c @@ -132,12 +132,25 @@ static int __devinit ep8248e_mdio_probe(struct of_device *ofdev, return -ENOMEM; bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); + if (bus->irq == NULL) { + ret = -ENOMEM; + goto err_free_bus; + } bus->name = "ep8248e-mdio-bitbang"; bus->parent = &ofdev->dev; snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); - return of_mdiobus_register(bus, ofdev->node); + ret = of_mdiobus_register(bus, ofdev->node); + if (ret) + goto err_free_irq; + + return 0; +err_free_irq: + kfree(bus->irq); +err_free_bus: + free_mdio_bitbang(bus); + return ret; } static int ep8248e_mdio_remove(struct of_device *ofdev)