lkml.org 
[lkml]   [2017]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] iommu/amd: Check if domain is NULL before dereference it
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.

\
 
 \ /
  Last update: 2017-08-24 15:01    [W:0.070 / U:1.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site