All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it
Date: Thu, 24 Aug 2017 21:01:10 +0800	[thread overview]
Message-ID: <20170824130110.GI19768@x1> (raw)
In-Reply-To: <20170824125311.ymx27viis6rnhozy@mwanda>

On 08/24/17 at 03:53pm, Dan Carpenter wrote:
> On Thu, Aug 24, 2017 at 08:47:33PM +0800, Baoquan He wrote:
> > On 08/24/17 at 03:32pm, Dan Carpenter wrote:
> > > Take a look at this code for example.  But all the places which call
> > > get_domain() are the same:
> > > 
> > > drivers/iommu/amd_iommu.c
> > >   2648          page = virt_to_page(virt_addr);
> > >   2649          size = PAGE_ALIGN(size);
> > >   2650  
> > >   2651          domain = get_domain(dev);
> > >                          ^^^^^^^^^^^^^^
> > > imagined get_domain() returns NULL.
> > > 
> > >   2652          if (IS_ERR(domain))
> > >   2653                  goto free_mem;
> > >   2654  
> > >   2655          dma_dom = to_dma_ops_domain(domain);
> > >                           ^^^^^^^^^^^^^^^^^^^^^^^^^
> > > This will Oops.
> > 
> > I see, it's a problem. Thanks for telling!
> > 
> > How about below change? But I am not very sure which errno should be
> > picked, seems the latter one, EBUSY is better since it has passed the
> > check_device() checking.
> 
> Looks good to me.  You know better than I do which errno is best, so
> I'll leave that to you.

OK, thanks! Then let me post v2 with it.

WARNING: multiple messages have this Message-ID (diff)
From: Baoquan He <bhe@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	joro@8bytes.org
Subject: Re: [PATCH] iommu/amd: Check if domain is NULL before dereference it
Date: Thu, 24 Aug 2017 21:01:10 +0800	[thread overview]
Message-ID: <20170824130110.GI19768@x1> (raw)
In-Reply-To: <20170824125311.ymx27viis6rnhozy@mwanda>

On 08/24/17 at 03:53pm, Dan Carpenter wrote:
> On Thu, Aug 24, 2017 at 08:47:33PM +0800, Baoquan He wrote:
> > On 08/24/17 at 03:32pm, Dan Carpenter wrote:
> > > Take a look at this code for example.  But all the places which call
> > > get_domain() are the same:
> > > 
> > > drivers/iommu/amd_iommu.c
> > >   2648          page = virt_to_page(virt_addr);
> > >   2649          size = PAGE_ALIGN(size);
> > >   2650  
> > >   2651          domain = get_domain(dev);
> > >                          ^^^^^^^^^^^^^^
> > > imagined get_domain() returns NULL.
> > > 
> > >   2652          if (IS_ERR(domain))
> > >   2653                  goto free_mem;
> > >   2654  
> > >   2655          dma_dom = to_dma_ops_domain(domain);
> > >                           ^^^^^^^^^^^^^^^^^^^^^^^^^
> > > This will Oops.
> > 
> > I see, it's a problem. Thanks for telling!
> > 
> > How about below change? But I am not very sure which errno should be
> > picked, seems the latter one, EBUSY is better since it has passed the
> > check_device() checking.
> 
> Looks good to me.  You know better than I do which errno is best, so
> I'll leave that to you.

OK, thanks! Then let me post v2 with it.

  reply	other threads:[~2017-08-24 13:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 11:56 [PATCH] iommu/amd: Check if domain is NULL before dereference it Baoquan He
     [not found] ` <1503575807-15746-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-08-24 12:11   ` Dan Carpenter
2017-08-24 12:11     ` Dan Carpenter
2017-08-24 12:22     ` Baoquan He
2017-08-24 12:22       ` Baoquan He
2017-08-24 12:32       ` Dan Carpenter
2017-08-24 12:47         ` Baoquan He
2017-08-24 12:47           ` Baoquan He
2017-08-24 12:53           ` Dan Carpenter
2017-08-24 13:01             ` Baoquan He [this message]
2017-08-24 13:01               ` Baoquan He

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=20170824130110.GI19768@x1 \
    --to=bhe-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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.