Received: by 10.213.65.68 with SMTP id h4csp3679771imn; Tue, 10 Apr 2018 02:59:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx49wD9I/jMz3QjeL8oCkitk+E8YX+eVMGhbCJLFSd9zSCRLudUozZgjRoXCy+Xb14SnYlnvm X-Received: by 10.99.135.199 with SMTP id i190mr27434465pge.2.1523354374129; Tue, 10 Apr 2018 02:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523354374; cv=none; d=google.com; s=arc-20160816; b=JA04b1CCrhK7D0ou6kgX752lJ3Oxttb6Df9K7ibEcV7ViiJXb2v6x6wu0oXT7Uoa6r fs0Sy439mCUUvxplmGvCJ+OBl7Y56mBp2rMzhrBwgelUumbuYiUGdiNNdCbu5/4N9TjK lWKC7UTy2j+EsJ1ttcUKLMZ5bZOJJ4I/IAuopcLolxjAbxX9JPJvNDkRXDCBGIJ3Tk6p ElkvEqiBFVejHBCVm4D6w4rkzDovq0aQA8Me2rV96kJ4dXwWaJ8iPYbXdWFtZstwgKrb fj75WrjMMZfeB7ZHyYWTX6ZldkJY+sIi6JQmRHGZq7O7gEEtbyiEZqQB9MsgrBfqF/vr /G2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ad22hLbShNeMk4RjyyNmy5OucmsHFKBU4jGDgj9/DMA=; b=K9ev/014WxrKEDCVXKyUnqLs0UXzs8QYEunLg6rVWZyeuLB8xPNfhkrLK5eI4d2egZ JNveegavs/Hhr3U7orsKz2LPc9yetkKr2FQZ9XiepbCY5qjIEUg5jAlhUq51uLUrVCmg V1SvE30dfe1PQSsJQBftiDtU9PTiqAgPV0rO70NdjxdApEue+dT/fR5PnhqnQyeKa5fK UWKi8hPuG2FM77LyAx/W7d8sCgAfsZbvy0boQgIrwXy51j0CbxaUvhb0EURUgbx7iuGZ 0iVTJMGD8sUSWU4zhYnI+GJdSMUrOY7/kleKHX6w+dl9Kxk00KHLx7MvdwgDqIafNnCs Ls+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HFWch5y4; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t137si1558716pgb.288.2018.04.10.02.58.57; Tue, 10 Apr 2018 02:59:34 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HFWch5y4; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbeDJJzT (ORCPT + 99 others); Tue, 10 Apr 2018 05:55:19 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:42759 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752345AbeDJJzR (ORCPT ); Tue, 10 Apr 2018 05:55:17 -0400 Received: by mail-pl0-f68.google.com with SMTP id t20-v6so4304881ply.9; Tue, 10 Apr 2018 02:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ad22hLbShNeMk4RjyyNmy5OucmsHFKBU4jGDgj9/DMA=; b=HFWch5y4P9ZNbeHxcDo/crqCYrdbGz1z1IjodN3rnTCYlN77ceKDHm0mwpiqqWgM2e I63RFSP43T820Ask+2j34656BZBU8iER5lKlVWo0pUApYuxdMFhHkgMyQqsVP103vHRI l46wvAApbZ+g3b3Hu6RnU69FZ21K3qQECDw0XCQnYJUC+qZwruWTovRotgEI23ll1Yrd bRxcAwjTg52/GIjcge8Nhtkh3T29+cbospJrUpBBQwAkoZ2pOyBOtE5X9HRXq0WX1ABz TBc75ZOLPIK+M4qAZ3oF3PXfW8vlxO542BPGoUrkR9qtHl4snXijWvubH2h+93XDSfTf jVTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ad22hLbShNeMk4RjyyNmy5OucmsHFKBU4jGDgj9/DMA=; b=Yj85fkcjc2awT3OQHB90cxQiEAaRh6PoYcpC2H4dbmjVRR87Lw2EsuP8w/mV+jdYzz 88Wn4bk+nLjSvS4oejnPAzzuuid3taDRBXCw+Bf+XsoFWlNZf+T+ym1MtX/BVWLicQt7 6wRU2rJVtS9JUhgKfTSanRdB+lPpkSXvpxSAWFMF2HcgZ6ymSAUED1WyQBKlKji1rbZ6 lHaauHIx33+vxXTResH3DboBTzRJrUGLf9meOu69C7Vx/euFQmlRPNDowz0wpTh4I+72 YWZxs8Wp3hWK0eN0j897bTp7oPrv00NOyHWPnb9FF8T/kSjNr3BAQSI5JDvz3Xt1NM/Q +Q0Q== X-Gm-Message-State: AElRT7FTROe+WQsWI1yAu6R2L3MRNTQLK++iJOALPcZtd6d/reQck/yB k29J+g5qhzWXLEAwHuXZeD6HCu3kIQ2r6ZB5OPs= X-Received: by 2002:a17:902:6a85:: with SMTP id n5-v6mr43126774plk.313.1523354116826; Tue, 10 Apr 2018 02:55:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.184.133 with HTTP; Tue, 10 Apr 2018 02:54:36 -0700 (PDT) In-Reply-To: <20180405162006.GA2199@embeddedor.com> References: <20180405162006.GA2199@embeddedor.com> From: Xue Liu Date: Tue, 10 Apr 2018 11:54:36 +0200 Message-ID: Subject: Re: [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe To: "Gustavo A. R. Silva" Cc: Alexander Aring , Stefan Schmidt , linux-wpan - ML , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hallo, Thanks for the fix. It looks good. ACK-by: Xue Liu On 5 April 2018 at 18:20, 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; > } > -- > 2.7.4 >