All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Battersby <tonyb-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
To: John Garry <john.garry-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
	Matthew Wilcox <willy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
	Marek Szyprowski
	<m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org
Cc: "linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v4 2/9] dmapool: remove checks for dev == NULL
Date: Mon, 12 Nov 2018 12:06:08 -0500	[thread overview]
Message-ID: <0c364366-fe92-0ff8-4fdf-a2c597ed0fa8@cybernetics.com> (raw)
In-Reply-To: <5a32095b-4626-9967-784b-9becac303994-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

On 11/12/18 11:32 AM, John Garry wrote:
> On 12/11/2018 15:42, Tony Battersby wrote:
>> dmapool originally tried to support pools without a device because
>> dma_alloc_coherent() supports allocations without a device.  But nobody
>> ended up using dma pools without a device, so the current checks in
>> dmapool.c for pool->dev == NULL are both insufficient and causing bloat.
>> Remove them.
>>
> As an aside, is it right that dma_pool_create() does not actually reject 
> dev==NULL and would crash from a NULL-pointer dereference?
>
> Thanks,
> John
>
When passed a NULL dev, dma_pool_create() will already crash with a
NULL-pointer dereference before this patch series, because it checks for
dev == NULL in some places but not others.  Specifically, it will crash
in one of these two places in dma_pool_create():

	retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev));
-or-
	if (list_empty(&dev->dma_pools))

So removing the checks for dev == NULL will not make previously-working
code to start crashing suddenly.  And since passing dev == NULL would be
an API misuse error and not a runtime error, I would rather not add a
new check to reject it.

Tony
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Tony Battersby <tonyb@cybernetics.com>
To: John Garry <john.garry@huawei.com>,
	Matthew Wilcox <willy@infradead.org>,
	Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	iommu@lists.linux-foundation.org, linux-mm@kvack.org
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH v4 2/9] dmapool: remove checks for dev == NULL
Date: Mon, 12 Nov 2018 12:06:08 -0500	[thread overview]
Message-ID: <0c364366-fe92-0ff8-4fdf-a2c597ed0fa8@cybernetics.com> (raw)
In-Reply-To: <5a32095b-4626-9967-784b-9becac303994@huawei.com>

On 11/12/18 11:32 AM, John Garry wrote:
> On 12/11/2018 15:42, Tony Battersby wrote:
>> dmapool originally tried to support pools without a device because
>> dma_alloc_coherent() supports allocations without a device.  But nobody
>> ended up using dma pools without a device, so the current checks in
>> dmapool.c for pool->dev == NULL are both insufficient and causing bloat.
>> Remove them.
>>
> As an aside, is it right that dma_pool_create() does not actually reject 
> dev==NULL and would crash from a NULL-pointer dereference?
>
> Thanks,
> John
>
When passed a NULL dev, dma_pool_create() will already crash with a
NULL-pointer dereference before this patch series, because it checks for
dev == NULL in some places but not others.A  Specifically, it will crash
in one of these two places in dma_pool_create():

	retval = kmalloc_node(sizeof(*retval), GFP_KERNEL, dev_to_node(dev));
-or-
	if (list_empty(&dev->dma_pools))

So removing the checks for dev == NULL will not make previously-working
code to start crashing suddenly.A  And since passing dev == NULL would be
an API misuse error and not a runtime error, I would rather not add a
new check to reject it.

Tony

  parent reply	other threads:[~2018-11-12 17:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-12 15:42 [PATCH v4 2/9] dmapool: remove checks for dev == NULL Tony Battersby
2018-11-12 15:42 ` Tony Battersby
     [not found] ` <df529b6e-6744-b1af-01ce-a1b691fbcf0d-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
2018-11-12 16:32   ` John Garry
2018-11-12 16:32     ` John Garry
     [not found]     ` <5a32095b-4626-9967-784b-9becac303994-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2018-11-12 17:06       ` Tony Battersby [this message]
2018-11-12 17:06         ` Tony Battersby
2018-11-13  6:14   ` Matthew Wilcox
2018-11-13  6:14     ` Matthew Wilcox

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=0c364366-fe92-0ff8-4fdf-a2c597ed0fa8@cybernetics.com \
    --to=tonyb-vfae+i1/wji5uwnf+njydw@public.gmane.org \
    --cc=hch-jcswGhMUV9g@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=john.garry-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=willy-wEGCiKHe2LqWVfeAwA7xHQ@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.