public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: wu000273@umn.edu
Cc: dledford@redhat.com, leon@kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org, kjlu@umn.edu
Subject: Re: [PATCH] RDMA/core: fix missing release in add_port.
Date: Mon, 25 May 2020 10:03:40 -0300	[thread overview]
Message-ID: <20200525130340.GD744@ziepe.ca> (raw)
In-Reply-To: <20200525060656.2478-1-wu000273@umn.edu>

On Mon, May 25, 2020 at 01:06:56AM -0500, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
> 
> In function add_port(), pointer p is not released in error paths.
> Fix this issue by adding a kfree(p) into the end of error path.
> 
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
>  drivers/infiniband/core/sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index 087682e6969e..04a003378dfc 100644
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -1202,6 +1202,7 @@ static int add_port(struct ib_core_device *coredev, int port_num)
>  
>  err_put:
>  	kobject_put(&p->kobj);
> +	kfree(p);
>  	return ret;
>  }

Er, no, kobject_put does the kfree

There is a bug here, it is calling kfree() after kobject_init_and_add
fails, which is wrong, it should be goto err_put

Jason

      reply	other threads:[~2020-05-25 13:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  6:06 [PATCH] RDMA/core: fix missing release in add_port wu000273
2020-05-25 13:03 ` Jason Gunthorpe [this message]

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=20200525130340.GD744@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=dledford@redhat.com \
    --cc=kjlu@umn.edu \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=wu000273@umn.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox