public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
	Leon Romanovsky <leonro@mellanox.com>,
	linux-rdma@vger.kernel.org, Yishai Hadas <yishaih@mellanox.com>
Subject: Re: [PATCH rdma-rc] RDMA/core: Check that type_attrs is not NULL prior access
Date: Tue, 16 Jun 2020 16:20:54 -0300	[thread overview]
Message-ID: <20200616192054.GE6578@ziepe.ca> (raw)
In-Reply-To: <20200616105813.2428412-1-leon@kernel.org>

On Tue, Jun 16, 2020 at 01:58:13PM +0300, Leon Romanovsky wrote:
> diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
> index 38de4942c682..16b86635d752 100644
> +++ b/drivers/infiniband/core/rdma_core.c
> @@ -470,40 +470,41 @@ static struct ib_uobject *
>  alloc_begin_fd_uobject(const struct uverbs_api_object *obj,
>  		       struct uverbs_attr_bundle *attrs)
>  {
> -	const struct uverbs_obj_fd_type *fd_type =
> -		container_of(obj->type_attrs, struct uverbs_obj_fd_type, type);
> +	const struct uverbs_obj_fd_type *fd_type;
>  	int new_fd;
>  	struct ib_uobject *uobj;
>  	struct file *filp;
> 
> +	uobj = alloc_uobj(attrs, obj);
> +	if (IS_ERR(uobj))
> +		return uobj;
> +
> +	fd_type =
> +		container_of(obj->type_attrs, struct uverbs_obj_fd_type, type);
>  	if (WARN_ON(fd_type->fops->release != &uverbs_uobject_fd_release &&
> -		    fd_type->fops->release != &uverbs_async_event_release))
> +		    fd_type->fops->release != &uverbs_async_event_release)) {
> +		uverbs_uobject_put(uobj);
>  		return ERR_PTR(-EINVAL);
> +	}

I feel like this is a bit cleaner with a goto unwind ?

Jason

  reply	other threads:[~2020-06-16 19:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 10:58 [PATCH rdma-rc] RDMA/core: Check that type_attrs is not NULL prior access Leon Romanovsky
2020-06-16 19:20 ` Jason Gunthorpe [this message]
2020-06-17  4:39   ` Leon Romanovsky

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=20200616192054.GE6578@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=dledford@redhat.com \
    --cc=leon@kernel.org \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=yishaih@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox