From patchwork Wed Jul 17 06:21:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wei_wang@realsil.com.cn X-Patchwork-Id: 2828466 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BDD9FC0AB2 for ; Wed, 17 Jul 2013 06:22:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7D2520114 for ; Wed, 17 Jul 2013 06:22:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8DE172010C for ; Wed, 17 Jul 2013 06:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752036Ab3GQGWB (ORCPT ); Wed, 17 Jul 2013 02:22:01 -0400 Received: from rtits2.realtek.com ([60.250.210.242]:45473 "EHLO rtits2.realtek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751946Ab3GQGWA (ORCPT ); Wed, 17 Jul 2013 02:22:00 -0400 X-SpamFilter-By: BOX Solutions SpamTrap 5.34 with qID r6H6K9dO015594, This message is accepted by code: ctloc85258 Received: from rsex2.realsil.com.cn (rsn1.realsil.com.cn[172.29.17.3](maybeforged)) by rtits2.realtek.com (8.14.5/2.36/5.52) with ESMTP id r6H6K9dO015594; Wed, 17 Jul 2013 14:21:48 +0800 Received: from localhost (172.29.41.8) by RSEX2.realsil.com.cn (172.29.17.3) with Microsoft SMTP Server id 14.3.123.3; Wed, 17 Jul 2013 14:21:13 +0800 From: To: CC: , , Wei WANG Subject: [PATCH] mmc/core: free mmc_card when cmd 3, 9, 7 got failed in mmc_sd_init_card Date: Wed, 17 Jul 2013 14:21:10 +0800 Message-ID: <1374042070-32765-1-git-send-email-wei_wang@realsil.com.cn> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Originating-IP: [172.29.41.8] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei WANG In function mmc_sd_init_card, if command 3/9/7 got failed, mmc_card allocated just before won't be freed. This would cause memory leak. Signed-off-by: Wei WANG --- drivers/mmc/core/sd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 176d125..1240a85 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -942,13 +942,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, if (!mmc_host_is_spi(host)) { err = mmc_send_relative_addr(host, &card->rca); if (err) - return err; + goto free_card; } if (!oldcard) { err = mmc_sd_get_csd(host, card); if (err) - return err; + goto free_card; mmc_decode_cid(card); } @@ -959,7 +959,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, if (!mmc_host_is_spi(host)) { err = mmc_select_card(card); if (err) - return err; + goto free_card; } err = mmc_sd_setup_card(host, card, oldcard != NULL);