From: Doug Ledford <dledford@redhat.com>
To: oulijun <oulijun@huawei.com>,
Colin King <colin.king@canonical.com>,
Wei Hu <xavier.huwei@huawei.com>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
linux-rdma@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][V2] IB/hns: fix memory leak on ah on error return path
Date: Wed, 16 Aug 2017 15:31:17 +0000 [thread overview]
Message-ID: <1502897477.33760.11.camel@redhat.com> (raw)
In-Reply-To: <52e486f3-4cca-d31c-812e-4027d98b867b@huawei.com>
On Fri, 2017-08-11 at 09:45 +0800, oulijun wrote:
> 在 2017/8/9 1:41, Colin King 写道:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > 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 <colin.king@canonical.com>
> > ---
> > 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 <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
WARNING: multiple messages have this Message-ID (diff)
From: Doug Ledford <dledford@redhat.com>
To: oulijun <oulijun@huawei.com>,
Colin King <colin.king@canonical.com>,
Wei Hu <xavier.huwei@huawei.com>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
linux-rdma@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][V2] IB/hns: fix memory leak on ah on error return path
Date: Wed, 16 Aug 2017 11:31:17 -0400 [thread overview]
Message-ID: <1502897477.33760.11.camel@redhat.com> (raw)
In-Reply-To: <52e486f3-4cca-d31c-812e-4027d98b867b@huawei.com>
On Fri, 2017-08-11 at 09:45 +0800, oulijun wrote:
> 在 2017/8/9 1:41, Colin King 写道:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > 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 <colin.king@canonical.com>
> > ---
> > 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 <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
next prev parent reply other threads:[~2017-08-16 15:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 17:41 [PATCH][V2] IB/hns: fix memory leak on ah on error return path Colin King
2017-08-08 17:41 ` Colin King
[not found] ` <52e486f3-4cca-d31c-812e-4027d98b867b@huawei.com>
2017-08-16 15:31 ` Doug Ledford [this message]
2017-08-16 15:31 ` Doug Ledford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502897477.33760.11.camel@redhat.com \
--to=dledford@redhat.com \
--cc=colin.king@canonical.com \
--cc=hal.rosenstock@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=oulijun@huawei.com \
--cc=sean.hefty@intel.com \
--cc=xavier.huwei@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.