Received: by 10.213.65.68 with SMTP id h4csp3738892imn; Tue, 10 Apr 2018 04:03:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+mWOUahHTmGieoVyoKaeitVX7xZpEe2Iq4tcrGPe7hnsduuDgcI4Uu+mBBtLScci4MwWUv X-Received: by 10.101.72.9 with SMTP id h9mr27632518pgs.88.1523358196956; Tue, 10 Apr 2018 04:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523358196; cv=none; d=google.com; s=arc-20160816; b=ec3uhYQZYpeP08d7pum8rCQttfUpEU73qXa9mWe0JyQvURGDRAPBCuet5yzmAYIn5Z nG1qBczcQpzicYw8a6aMAf/da5FjZ+wz0r4pMJ8GzUUP8G/JfD/WeMu7mqF0AZKqM4BM 8FcJ28ooZEdOGErxoZx7mPiPeBWSRzeW9T+rCZPWkr29bwlNTIVC3O6rjDS9WP7wIIte FVubVeR04UWlGWNpn4ESO3rpGkibvpoF1d4rADtpnhzjPnwHuTHah3UqJcoOEBa5X63M yZEnxs3CktvSXDYtmYT8GdV/n2a+ahPtWEmY3mnCI7YJFOWtPpWAsYaXTVMfYyP87ctG 76Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=S1Slik2oml+BcHBZ1cX4lcXjK3IPv2qTQOBLwFdDuPg=; b=uROoOI77PbnqBCWwE57lalvWDEGsIX47d1Elgv20srlyNi+GLf/CnRh3nZCoILHbbc AyV5lBGqgLmA41MIYk9RupJ4jBZuczbUoDg8TT3FYHo/V0vS4SAZSbyQWO/CLnviqh7v E+jkuIXLRbK/srnI1oaRuAfmhmfYflRUm4E1dr8FjtavwH784YbIIkalyaqdhCTEfnSZ X4cj38KKMBCOFfenn4KzOxVGFNCFSUGakwoUskBCxtvyaDH0vTEVBQqUG0erD3wMz03b LX582X6jO0l0sJQWx3OrL8IBmoLEyr+GcsJE78zJvyPak3WCXlox5GZ9KLdqRP92Sg26 mMkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i133si1646980pgc.299.2018.04.10.04.02.40; Tue, 10 Apr 2018 04:03:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753108AbeDJK6Y (ORCPT + 99 others); Tue, 10 Apr 2018 06:58:24 -0400 Received: from osg.samsung.com ([64.30.133.232]:54877 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbeDJK6W (ORCPT ); Tue, 10 Apr 2018 06:58:22 -0400 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id 53EE93C1F6; Tue, 10 Apr 2018 03:58:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com Received: from osg.samsung.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UkYdYNChragN; Tue, 10 Apr 2018 03:58:20 -0700 (PDT) Received: from [192.168.2.108] (p4FE71B8C.dip0.t-ipconnect.de [79.231.27.140]) by osg.samsung.com (Postfix) with ESMTPSA id 890E33C1ED; Tue, 10 Apr 2018 03:58:19 -0700 (PDT) Subject: Re: [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe To: "Gustavo A. R. Silva" , Xue Liu , Alexander Aring Cc: linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180405162006.GA2199@embeddedor.com> From: Stefan Schmidt Message-ID: <59fce20c-0450-e59b-4db4-94bbb2372c9c@osg.samsung.com> Date: Tue, 10 Apr 2018 12:58:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180405162006.GA2199@embeddedor.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 04/05/2018 06:20 PM, Gustavo A. R. Silva wrote: > Free allocated memory for pdata before return. > > Addresses-Coverity-ID: 1466096 ("Resource leak") > Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver") > Signed-off-by: Gustavo A. R. Silva > --- > drivers/net/ieee802154/mcr20a.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c > index 55a22c7..944470d 100644 > --- a/drivers/net/ieee802154/mcr20a.c > +++ b/drivers/net/ieee802154/mcr20a.c > @@ -1267,7 +1267,7 @@ mcr20a_probe(struct spi_device *spi) > ret = mcr20a_get_platform_data(spi, pdata); > if (ret < 0) { > dev_crit(&spi->dev, "mcr20a_get_platform_data failed.\n"); > - return ret; > + goto free_pdata; > } > > /* init reset gpio */ > @@ -1275,7 +1275,7 @@ mcr20a_probe(struct spi_device *spi) > ret = devm_gpio_request_one(&spi->dev, pdata->rst_gpio, > GPIOF_OUT_INIT_HIGH, "reset"); > if (ret) > - return ret; > + goto free_pdata; > } > > /* reset mcr20a */ > @@ -1291,7 +1291,8 @@ mcr20a_probe(struct spi_device *spi) > hw = ieee802154_alloc_hw(sizeof(*lp), &mcr20a_hw_ops); > if (!hw) { > dev_crit(&spi->dev, "ieee802154_alloc_hw failed\n"); > - return -ENOMEM; > + ret = -ENOMEM; > + goto free_pdata; > } > > /* init mcr20a local data */ > @@ -1366,6 +1367,8 @@ mcr20a_probe(struct spi_device *spi) > > free_dev: > ieee802154_free_hw(lp->hw); > +free_pdata: > + kfree(pdata); > > return ret; > } This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks! regards Stefan Schmidt