From patchwork Thu Dec 18 18:23:33 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 14715 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id EBB76DDF60 for ; Fri, 19 Dec 2008 05:38:21 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from buildserver.ru.mvista.com (unknown [85.21.88.6]) by ozlabs.org (Postfix) with ESMTP id 86355DDF17 for ; Fri, 19 Dec 2008 05:23:37 +1100 (EST) Received: from localhost (unknown [10.150.0.9]) by buildserver.ru.mvista.com (Postfix) with ESMTP id 3BEC5881E; Thu, 18 Dec 2008 23:23:34 +0400 (SAMT) Date: Thu, 18 Dec 2008 21:23:33 +0300 From: Anton Vorontsov To: Jeff Garzik Subject: [PATCH 5/6] ucc_geth: Fix IO memory (un)mapping code Message-ID: <20081218182333.GE30682@oksana.dev.rtsoft.ru> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Cc: netdev@vger.kernel.org, Timur Tabi , linuxppc-dev@ozlabs.org, Andy Fleming , Li Yang , David Miller X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 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@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org The driver doesn't check ioremap() return value, and doesn't free the remapped memory. This patch fixes it. Signed-off-by: Anton Vorontsov --- drivers/net/ucc_geth.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 70208c6..20c065c 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c @@ -2218,7 +2218,10 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth) while (!list_empty(&ugeth->ind_hash_q)) put_enet_addr_container(ENET_ADDR_CONT_ENTRY (dequeue(&ugeth->ind_hash_q))); - + if (ugeth->ug_regs) { + iounmap(ugeth->ug_regs); + ugeth->ug_regs = NULL; + } } static void ucc_geth_set_multi(struct net_device *dev) @@ -2423,7 +2426,12 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth) return -ENOMEM; } - ugeth->ug_regs = (struct ucc_geth __iomem *) ioremap(uf_info->regs, sizeof(struct ucc_geth)); + ugeth->ug_regs = ioremap(uf_info->regs, sizeof(*ugeth->ug_regs)); + if (!ugeth->ug_regs) { + if (netif_msg_probe(ugeth)) + ugeth_err("%s: Failed to ioremap regs.", __func__); + return -ENOMEM; + } return 0; } @@ -3691,7 +3699,7 @@ static int ucc_geth_open(struct net_device *dev) if (err) { if (netif_msg_ifup(ugeth)) ugeth_err("%s: Cannot configure internal struct, aborting.", dev->name); - return err; + goto out_err_stop; } napi_enable(&ugeth->napi); @@ -3754,6 +3762,7 @@ static int ucc_geth_open(struct net_device *dev) out_err: napi_disable(&ugeth->napi); +out_err_stop: ucc_geth_stop(ugeth); return err; }