From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751714AbdHPPbV (ORCPT ); Wed, 16 Aug 2017 11:31:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60314 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531AbdHPPbT (ORCPT ); Wed, 16 Aug 2017 11:31:19 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 449C261D19 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dledford@redhat.com Message-ID: <1502897477.33760.11.camel@redhat.com> Subject: Re: [PATCH][V2] IB/hns: fix memory leak on ah on error return path From: Doug Ledford To: oulijun , Colin King , Wei Hu , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 16 Aug 2017 11:31:17 -0400 In-Reply-To: <52e486f3-4cca-d31c-812e-4027d98b867b@huawei.com> References: <20170808174102.28568-1-colin.king@canonical.com> <52e486f3-4cca-d31c-812e-4027d98b867b@huawei.com> Organization: Red Hat, Inc. Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 16 Aug 2017 15:31:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-08-11 at 09:45 +0800, oulijun wrote: > 在 2017/8/9 1:41, Colin King 写道: > > From: Colin Ian King > > > > When dmac is NULL, ah is not being freed on the error return path. > > Fix > > this by kfree'ing it. > > > > Detected by CoverityScan, CID#1452636 ("Resource Leak") > > > > Fixes: d8966fcd4c25 ("IB/core: Use rdma_ah_attr accessor > > functions") > > Signed-off-by: Colin Ian King > > --- > > drivers/infiniband/hw/hns/hns_roce_ah.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c > > b/drivers/infiniband/hw/hns/hns_roce_ah.c > > index f78a733a63ec..d545302b8ef8 100644 > > --- a/drivers/infiniband/hw/hns/hns_roce_ah.c > > +++ b/drivers/infiniband/hw/hns/hns_roce_ah.c > > @@ -64,8 +64,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd > > *ibpd, > > } else { > > u8 *dmac = rdma_ah_retrieve_dmac(ah_attr); > > > > - if (!dmac) > > + if (!dmac) { > > + kfree(ah); > > return ERR_PTR(-EINVAL); > > + } > > memcpy(ah->av.mac, dmac, ETH_ALEN); > > } > > > > Thank you for reviewing and fixing Thanks, patch applied to -rc. -- Doug Ledford GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD