Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1663461

Re: [PATCH] arm64/dma-mapping: Fix null-pointer check

From Catalin Marinas <catalin.marinas@arm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] arm64/dma-mapping: Fix null-pointer check
Date 2017-06-12 14:30 +0200
Message-ID <tRwDM-22k-3@gated-at.bofh.it> (permalink)
References <tQUyt-3bS-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Jun 10, 2017 at 12:41:10PM -0700, Olav Haugan wrote:
> @@ -149,6 +140,11 @@ static void *__dma_alloc(struct device *dev, size_t size,
>  	bool coherent = is_device_dma_coherent(dev);
>  	pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL, false);
>  
> +	if (!dev) {
> +		WARN_ONCE(1, "Use an actual device structure for DMA allocation\n");
> +		return NULL;
> +	}
> +
>  	size = PAGE_ALIGN(size);
>  
>  	if (!coherent && !gfpflags_allow_blocking(flags)) {
> @@ -192,8 +188,13 @@ static void __dma_free(struct device *dev, size_t size,
>  		       void *vaddr, dma_addr_t dma_handle,
>  		       unsigned long attrs)
>  {
> -	void *swiotlb_addr = phys_to_virt(dma_to_phys(dev, dma_handle));
> +	void *swiotlb_addr;
>  
> +	if (!dev) {
> +		WARN_ONCE(1, "Use an actual device structure for DMA free\n");
> +		return;
> +	}
> +	swiotlb_addr = phys_to_virt(dma_to_phys(dev, dma_handle));

I don't think we need the checks anymore. With commit 1dccb598df54
("arm64: simplify dma_get_ops") __generic_dma_ops() returns
dummy_dma_ops when dev == NULL, so the above __dma_alloc/__dma_free
functions would not be called.

-- 
Catalin

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] arm64/dma-mapping: Fix null-pointer check Olav Haugan <ohaugan@codeaurora.org> - 2017-06-10 21:50 +0200
  Re: [PATCH] arm64/dma-mapping: Fix null-pointer check Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-06-11 00:10 +0200
    Re: [PATCH] arm64/dma-mapping: Fix null-pointer check Olav Haugan <ohaugan@codeaurora.org> - 2017-06-12 22:40 +0200
  Re: [PATCH] arm64/dma-mapping: Fix null-pointer check Catalin Marinas <catalin.marinas@arm.com> - 2017-06-12 14:30 +0200
    Re: [PATCH] arm64/dma-mapping: Fix null-pointer check Olav Haugan <ohaugan@codeaurora.org> - 2017-06-12 22:40 +0200
    Re: [PATCH] arm64/dma-mapping: Fix null-pointer check Olav Haugan <ohaugan@codeaurora.org> - 2017-06-12 23:00 +0200
      Re: [PATCH] arm64/dma-mapping: Fix null-pointer check Catalin Marinas <catalin.marinas@arm.com> - 2017-06-13 11:10 +0200

csiph-web