Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752553Ab3EIFBO (ORCPT ); Thu, 9 May 2013 01:01:14 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:46216 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121Ab3EIFBI (ORCPT ); Thu, 9 May 2013 01:01:08 -0400 From: Libo Chen To: , , CC: , , , , Libo Chen , Libo Chen Subject: [PATCH 4/4] usb: tilegx: fix memleak when create hcd fail Date: Thu, 9 May 2013 12:58:11 +0800 Message-ID: <1368075491-38728-5-git-send-email-libo.chen@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 In-Reply-To: <1368075491-38728-1-git-send-email-libo.chen@huawei.com> References: <1368075491-38728-1-git-send-email-libo.chen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.135.72.158] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1189 Lines: 43 From: Libo Chen When usb_create_hcd fail, we should call gxio_usb_host_destroy Signed-off-by: Libo Chen --- drivers/usb/host/ohci-tilegx.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ohci-tilegx.c b/drivers/usb/host/ohci-tilegx.c index 1ae7b28..5888fc4 100644 --- a/drivers/usb/host/ohci-tilegx.c +++ b/drivers/usb/host/ohci-tilegx.c @@ -112,8 +112,10 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev) hcd = usb_create_hcd(&ohci_tilegx_hc_driver, &pdev->dev, dev_name(&pdev->dev)); - if (!hcd) - return -ENOMEM; + if (!hcd){ + ret = -ENOMEM; + goto err_hcd; + } /* * We don't use rsrc_start to map in our registers, but seems like @@ -165,6 +167,7 @@ err_have_irq: err_no_irq: tilegx_stop_ohc(); usb_put_hcd(hcd); +err_hcd: gxio_usb_host_destroy(&pdata->usb_ctx); return ret; } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/