From patchwork Fri Oct 5 22:10:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Senna Tschudin X-Patchwork-Id: 189612 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3E7202C00C1 for ; Sat, 6 Oct 2012 08:11:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757695Ab2JEWLM (ORCPT ); Fri, 5 Oct 2012 18:11:12 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:56587 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757660Ab2JEWLK (ORCPT ); Fri, 5 Oct 2012 18:11:10 -0400 Received: by mail-wg0-f44.google.com with SMTP id dr13so1865641wgb.1 for ; Fri, 05 Oct 2012 15:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=YyVwNpTtLeVR40WMluOmayFKrWwk0IAUK/j/kr3EMMI=; b=BWcPdR5qRKV9JCY7FvP64MpoyGsnTfuuCpsfAFXisSsRArZg98sKM9dtiDoNEarYM7 8gF8ASGdGNf6jMJ5MZv21syS0Sg90wrXUDmyAyziANDi2kD0WM063Ss21wkNmIXwbLx2 fHBBmgSfaHaqEApwaFtxvhLfuGmsdJCCOR7jmbYtyuqe6KZS6nfp8DZS5Mf/f7WksAXZ 8ClokFvdg5eSIu0hxSpWVYh4xeF+bIYj8gCYvzqvPgV9NuRToRcv4tSEEhipr1/X+P12 Jogm1ORPh5XbnKptfFlCEy88ze8WlKRJUIpqEQDWY5eViBCLimKlKdyMxAUdILvPX6vN pjrQ== Received: by 10.180.91.169 with SMTP id cf9mr6114028wib.1.1349475068843; Fri, 05 Oct 2012 15:11:08 -0700 (PDT) Received: from ace.home ([37.175.200.243]) by mx.google.com with ESMTPS id fb20sm5234544wid.1.2012.10.05.15.11.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Oct 2012 15:11:07 -0700 (PDT) From: Peter Senna Tschudin To: davem@davemloft.net Cc: danny.kukawka@bisect.de, mcuos.com@gmail.com, joe@perches.com, florian@openwrt.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Peter Senna Tschudin Subject: [PATCH 14/20 V2] drivers/net/ethernet/amd/au1000_eth.c: fix error return code Date: Sat, 6 Oct 2012 00:10:52 +0200 Message-Id: <1349475053-11464-4-git-send-email-peter.senna@gmail.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1349475053-11464-1-git-send-email-peter.senna@gmail.com> References: <1349475053-11464-1-git-send-email-peter.senna@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Peter Senna Tschudin The function au1000_probe() return 0 for success and negative value for most of its internal tests failures. There are exceptions that are error cases going to err_out:. For this cases, the function abort its success execution path, but returns non negative value, making it dificult for a caller function to notice the error. This patch fixes the error cases that do not return negative values. This was found by Coccinelle, but the code change was made by hand. This patch is not robot generated. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Peter Senna Tschudin --- Change from V1: Updated commit message. See: http://www.kernelhub.org/?p=2&msg=139319 drivers/net/ethernet/amd/au1000_eth.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index 397596b..f195acf 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -1174,8 +1174,10 @@ static int __devinit au1000_probe(struct platform_device *pdev) snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", pdev->name, aup->mac_id); aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); - if (aup->mii_bus->irq == NULL) + if (aup->mii_bus->irq == NULL) { + err = -ENOMEM; goto err_out; + } for (i = 0; i < PHY_MAX_ADDR; ++i) aup->mii_bus->irq[i] = PHY_POLL; @@ -1190,7 +1192,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) goto err_mdiobus_reg; } - if (au1000_mii_probe(dev) != 0) + err = au1000_mii_probe(dev); + if (err != 0) goto err_out; pDBfree = NULL; @@ -1205,6 +1208,7 @@ static int __devinit au1000_probe(struct platform_device *pdev) } aup->pDBfree = pDBfree; + err = -ENODEV; for (i = 0; i < NUM_RX_DMA; i++) { pDB = au1000_GetFreeDB(aup); if (!pDB) @@ -1213,6 +1217,8 @@ static int __devinit au1000_probe(struct platform_device *pdev) aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr; aup->rx_db_inuse[i] = pDB; } + + err = -ENODEV; for (i = 0; i < NUM_TX_DMA; i++) { pDB = au1000_GetFreeDB(aup); if (!pDB)