Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752837AbdFLUud (ORCPT ); Mon, 12 Jun 2017 16:50:33 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59704 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583AbdFLUua (ORCPT ); Mon, 12 Jun 2017 16:50:30 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 56B9F60768 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ohaugan@codeaurora.org Date: Mon, 12 Jun 2017 13:50:28 -0700 From: Olav Haugan To: Catalin Marinas Cc: will.deacon@arm.com, robin.murphy@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] arm64/dma-mapping: Fix null-pointer check Message-ID: <20170612205028.y7a652hd46dakxdu@codeaurora.org> References: <20170610194110.27712-1-ohaugan@codeaurora.org> <20170612122903.GC24187@e104818-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170612122903.GC24187@e104818-lin.cambridge.arm.com> User-Agent: NeoMutt/20170428 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1426 Lines: 40 On 17-06-12 13:29:04, Catalin Marinas wrote: > 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. > We don't need the check in is_device_dma_coherent() either then right? -- .Olav The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project