Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp821482ybh; Wed, 22 Jul 2020 14:19:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLm14MuIu3IIo1u+43BuHlSoaj+bfc4DvdPTxVDOZ1RglAvgsGF0p++On9RnSiru0M1Wuk X-Received: by 2002:a17:906:c452:: with SMTP id ck18mr1460555ejb.415.1595452779711; Wed, 22 Jul 2020 14:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595452779; cv=none; d=google.com; s=arc-20160816; b=wv/rSkq1bX1BwpPUA4R18TOpNzt55LzcdwnyDtZ47gYgL0aLUWCEhvc6GSNWI28esC wphNPskeJQNUGRNMhI0Ohi9cCV0VrXKhiCYiQFpan3Dcc2ZfucsWpQ3Y9YnULa4bIzaH ODMRwdm290v3O7ndb52EvImkYJCmkJVg2RZubXm82T4/aY4WjwP9DotFCSwXNDhRt/Tq GiEX3stY42d8X5pSeymoZxLsLodSJeXDdGf5VAeZisGtw6boqBBUOv13OcAnSwJ9MAsv eBISmA4y3GqddPwTPc/KiA0FgDm+QcLYje08pL2LwY0JG9AusHlkyhpK8CrsbFNys9w1 9pTg== 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:dkim-signature; bh=/NCA8bXI3zfZYAohLjznoM/f/0f70sPbB/+ypwTdYwc=; b=bHB9x4apnfYNWTgyyKFNBGpKflcIWcm6iCjpbosHoLi/XabZLK5tzPCJOSE/UmYXmb wVU7dC/bxDqpLLzweBGnUgbtsIz4XSFPxyOY6Vq+qArqynqOtRZ7rIXOpZ2MIt0ieS6N 5gtNZaLKAZ3JPPN8hzRv3aX/x2pWc0dHBL182PkZZVHSOnoytCrhg6geeljuDGszuZeK waupHIw6+WEv6YGz3ASiht8R+hlbVWHJdkyF/Ru1rzW6p/31xh2pFSvXb7gb5V55sUmJ 7VMGE5W0PO0AQgJExMKo4JbZIUJDf4tlIshrh+MZy44CKyNmf3yUJybtQK9KDplUmFal zJKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@pensando.io header.s=google header.b=SHf1JmGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si740328ejy.206.2020.07.22.14.19.16; Wed, 22 Jul 2020 14:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@pensando.io header.s=google header.b=SHf1JmGT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732542AbgGVVSx (ORCPT + 99 others); Wed, 22 Jul 2020 17:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgGVVSw (ORCPT ); Wed, 22 Jul 2020 17:18:52 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F13CC0619DC for ; Wed, 22 Jul 2020 14:18:52 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id 8so2159243pjj.1 for ; Wed, 22 Jul 2020 14:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=/NCA8bXI3zfZYAohLjznoM/f/0f70sPbB/+ypwTdYwc=; b=SHf1JmGTnB3dAO02ZCUI+6CakGm0Ef6Boq9u7eNpki+17Ha09xS2ZLBYWpY3VMzFT3 u+7lxgl5oNVZvC0wFhSwysOqeqyKoI7jJIip6qgnkiWglcOa6GlBXxdWE+BMgA/PMGTq wx4TzANPIFUFMO5iOGVq9/MJNTNzyYw/GTftAaKhd0iydIvRpoEwwhWXlf8cLPHp30TB sbaXemgDpu1SkwiwBU1Hl2v003Sf6nVysUcoJnIFqYlKFi8qkRvHDdhsNFJMAW93yETa 5yNBOnrao3i9q6rZ63DqUtfWqx/DFAtRhx0/1ifYorhLdjAcBsfiLIraRTpmbF2fQj8y 1kQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=/NCA8bXI3zfZYAohLjznoM/f/0f70sPbB/+ypwTdYwc=; b=h9jjRClKvkPAdHmloiyQ8o6hjtI42nsX38W6wzttOoW6PaniXalnaWDuNh4FN2hx7q U8Eox/korlwL5URIAz4H/dkPAmtLQtZvLoQSVNnLAoKZycw2sgUMDW1EIDphlGLFo+e2 NR1OREMLSHoAZ249e1UGsWbgze5OI7ppd1w/ITbajXG81rGuEJ2eVFM1EUzphuotjG5r f57mcDR+a0TYelAclGjd8NcPrnAj7rN4ZMJrQjzX9VDALQoSu8nC4v/jYShZIF+E86CQ fpIRIoQJwB2y74xpBsKdiWjyCSo1Z68J5vn3K3J2oc2u0LK1BozK7Yt551E8uRb/RjaU Gu3g== X-Gm-Message-State: AOAM531AvsTAhepebUdgPb8w1skD/CCVu9fXZgbvTviMIWikn2TrniHk weVwYsL2iYe3gbb/8tVoQHwhQ+KIgWc= X-Received: by 2002:a17:90a:c592:: with SMTP id l18mr1236663pjt.119.1595452728690; Wed, 22 Jul 2020 14:18:48 -0700 (PDT) Received: from Shannons-MacBook-Pro.local (static-50-53-47-17.bvtn.or.frontiernet.net. [50.53.47.17]) by smtp.gmail.com with ESMTPSA id 207sm566591pfa.100.2020.07.22.14.18.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 14:18:47 -0700 (PDT) Subject: Re: [PATCH][next] ionic: fix memory leak of object 'lid' To: Colin King , Pensando Drivers , "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200722174003.962374-1-colin.king@canonical.com> From: Shannon Nelson Message-ID: Date: Wed, 22 Jul 2020 14:18:46 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200722174003.962374-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed 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 On 7/22/20 10:40 AM, Colin King wrote: > From: Colin Ian King > > Currently when netdev fails to allocate the error return path > fails to free the allocated object 'lid'. Fix this by setting > err to the return error code and jumping to a new label that > performs the kfree of lid before returning. > > Addresses-Coverity: ("Resource leak") > Fixes: 4b03b27349c0 ("ionic: get MTU from lif identity") > Signed-off-by: Colin Ian King > --- > drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c > index 7ad338a4653c..728dd6429d80 100644 > --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c > +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c > @@ -2034,7 +2034,8 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index > ionic->ntxqs_per_lif, ionic->ntxqs_per_lif); > if (!netdev) { > dev_err(dev, "Cannot allocate netdev, aborting\n"); > - return ERR_PTR(-ENOMEM); > + err = -ENOMEM; > + goto err_out_free_lid; > } > > SET_NETDEV_DEV(netdev, dev); > @@ -2120,6 +2121,7 @@ static struct ionic_lif *ionic_lif_alloc(struct ionic *ionic, unsigned int index > err_out_free_netdev: > free_netdev(lif->netdev); > lif = NULL; > +err_out_free_lid: > kfree(lid); > > return ERR_PTR(err); Thanks! Acked-by: Shannon Nelson