From patchwork Wed May 30 04:47:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 9037 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 361F923E58 for ; Wed, 30 May 2012 04:48:59 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 05A36A185A7 for ; Wed, 30 May 2012 04:48:58 +0000 (UTC) Received: by ggnf1 with SMTP id f1so3863496ggn.11 for ; Tue, 29 May 2012 21:48:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=5lCEXhWKrkSdqEPIeva/dxBrOQPlm2LOZbNU5vM7JHo=; b=d/4OI0OChu/Y1goz/Q+kVZZ4sKFzsaX2VJBT3zRawk4jMPiFGATPVKl19rtnlQxPQv hZXCzPgzB1bkN1VnZ3z8Tsr4yZCWvIc05lUa2+f9kadPNYT3FSf/B96rZTZBBQGp3fhB W12vzf6U1T89TnBW81xb9G/e/NFhp02Caik/+HiCeUV/ZmS1VEVW23WJX44wu/0SP/vS x5+fxlmpSiZ+4P/IFl9eiosBdlPcbCRhG+RQlvfQgo4bZmU+uRCJuz1as5rVk7vURdzA JogjIWO057TW2neNxC9TewPGQXQVhT6lh4B6rLl3I39yLnhtpEVStlss5WwuOogy6MMm Zk4Q== Received: by 10.50.222.202 with SMTP id qo10mr9536681igc.0.1338353338133; Tue, 29 May 2012 21:48:58 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp170292ibb; Tue, 29 May 2012 21:48:57 -0700 (PDT) Received: by 10.68.200.104 with SMTP id jr8mr46424855pbc.9.1338353337529; Tue, 29 May 2012 21:48:57 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id ic5si23533843pbc.267.2012.05.29.21.48.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 May 2012 21:48:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-pb0-f50.google.com with SMTP id rr4so7848934pbb.37 for ; Tue, 29 May 2012 21:48:57 -0700 (PDT) Received: by 10.68.233.193 with SMTP id ty1mr45527309pbc.47.1338353337231; Tue, 29 May 2012 21:48:57 -0700 (PDT) Received: from localhost.localdomain ([118.143.64.134]) by mx.google.com with ESMTPS id kd6sm25122557pbc.24.2012.05.29.21.48.54 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 May 2012 21:48:56 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, linus.walleij@stericsson.com, grant.likely@secretlab.ca, cjb@laptop.org, broonie@opensource.wolfsonmicro.com, sameo@linux.intel.com Cc: Lee Jones , netdev@vger.kernel.org Subject: [PATCH 19/22] net/smsc911x: Repair broken failure paths Date: Wed, 30 May 2012 12:47:37 +0800 Message-Id: <1338353260-10097-20-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1338353260-10097-1-git-send-email-lee.jones@linaro.org> References: <1338353260-10097-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQklfbWBUhnsG9uaxcsFnGNj8sDO1EdFz3wOB5PsJcHa5sraZzBAGIDwOnC0U0drcgm52MFy Current failure paths attempt to free resources which we failed to request and disable resources which we failed to enable ones. This leads to kernel oops/panic. This patch does some simple re-ordering to prevent this from happening. Cc: netdev@vger.kernel.org Signed-off-by: Lee Jones --- drivers/net/ethernet/smsc/smsc911x.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index dab9c6f..1466e5d 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2390,11 +2390,11 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev) retval = smsc911x_request_resources(pdev); if (retval) - goto out_return_resources; + goto out_request_resources_fail; retval = smsc911x_enable_resources(pdev); if (retval) - goto out_disable_resources; + goto out_enable_resources_fail; if (pdata->ioaddr == NULL) { SMSC_WARN(pdata, probe, "Error smsc911x base address invalid"); @@ -2501,8 +2501,9 @@ out_free_irq: free_irq(dev->irq, dev); out_disable_resources: (void)smsc911x_disable_resources(pdev); -out_return_resources: +out_enable_resources_fail: smsc911x_free_resources(pdev); +out_request_resources_fail: platform_set_drvdata(pdev, NULL); iounmap(pdata->ioaddr); free_netdev(dev);