From patchwork Sun Jul 19 16:13:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 29979 X-Patchwork-Delegate: davem@davemloft.net 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 B02DAB7088 for ; Mon, 20 Jul 2009 02:13:19 +1000 (EST) Received: by ozlabs.org (Postfix) id A00A7DDD0B; Mon, 20 Jul 2009 02:13:19 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 3DBFDDDD01 for ; Mon, 20 Jul 2009 02:13:19 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754740AbZGSQNI (ORCPT ); Sun, 19 Jul 2009 12:13:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754597AbZGSQNI (ORCPT ); Sun, 19 Jul 2009 12:13:08 -0400 Received: from mgw1.diku.dk ([130.225.96.91]:58057 "EHLO mgw1.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754512AbZGSQNH (ORCPT ); Sun, 19 Jul 2009 12:13:07 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 1B61752C3FD; Sun, 19 Jul 2009 18:13:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tnSr9dopClbO; Sun, 19 Jul 2009 18:13:04 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id 29DA552C368; Sun, 19 Jul 2009 18:13:04 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id A662C6DF835; Sun, 19 Jul 2009 18:12:31 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id 13E5B154B81; Sun, 19 Jul 2009 18:13:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id 10C3A1547DF; Sun, 19 Jul 2009 18:13:04 +0200 (CEST) Date: Sun, 19 Jul 2009 18:13:04 +0200 (CEST) From: Julia Lawall To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 10/10, corrected diffstat] drivers/net: Move a dereference below a NULL test Message-ID: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Julia Lawall If the NULL test is necessary, then the dereferences should be moved below the NULL test. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ type T; expression E,E1; identifier i,fld; statement S; @@ - T i = E->fld; + T i; ... when != E=E1 when != i BUG_ON (E == NULL||...); + i = E->fld; // Signed-off-by: Julia Lawall --- drivers/net/ibm_newemac/rgmii.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 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/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c index 1d5379d..8d76cb8 100644 --- a/drivers/net/ibm_newemac/rgmii.c +++ b/drivers/net/ibm_newemac/rgmii.c @@ -188,11 +188,12 @@ void rgmii_put_mdio(struct of_device *ofdev, int input) void rgmii_detach(struct of_device *ofdev, int input) { struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); - struct rgmii_regs __iomem *p = dev->base; - - mutex_lock(&dev->lock); + struct rgmii_regs __iomem *p; BUG_ON(!dev || dev->users == 0); + p = dev->base; + + mutex_lock(&dev->lock); RGMII_DBG(dev, "detach(%d)" NL, input);