Received: by 10.192.165.156 with SMTP id m28csp1078477imm; Wed, 18 Apr 2018 03:48:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx48i+ZJFvtM4YT2uUUsvl6pjuX90g6uN0RH7BK+vmiohZHFcaJejlLqEfPBIGPMXzxw71H9z X-Received: by 10.99.136.73 with SMTP id l70mr1367834pgd.49.1524048529283; Wed, 18 Apr 2018 03:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524048529; cv=none; d=google.com; s=arc-20160816; b=NXvCWngiOEusIyArcQ+OkCk6W62HDxE9QvIVjC5qnEf6DjH3xCXFPEkgSZJJGQHL4a 1d37E+bsTePWgeTe5nDEuu3NTbWmk1NxZAyzX4iHhtoIYLDOjVzIQFtX483ulJ/XHdJK 28Z5DJOOexy48XA1/j5McyY/y3sZqSe2Zp2ZpFJqR3h946TuT3Mo8NnXj1FwLnRpY/j6 YXqLvHLZYlRKHO1PRx5JCWEJk3wWg4RKZj9qE12YSuVx16S/7SE5aaJHr8CwOGoQ47CP oCgtNuHBigdC9Kjcf8vgKbNhQfcDPFZGhwhtZ5xxqdRkp6gP/SpkH4mhaO28hkPOU3QC Nq0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=LaLLOlfdv15O/bokhmx59IlXA5XcZ1RfdPXxHeoxk7c=; b=tpfNbdALKBxsKUDT2ON10tlRtTgT7A89mYowtYqRd5SfI2GvvKF6lOIJqdD3yHrGCo Kk2vY/bOepG70HslfIX1RFpNSCp4P2zsE6AeSHQ6lVZsxP6ll8hDUV7RhB9Z4nhSe34d l35IsmeyaCF0N6TJEUsho8W0L5gwMxjNcAexTnNs5RivNs12D5rddZozn2+mg8fAq5K8 CRj4Hk3pwHGLcBDlR56zwb+YlBcAN62OqVWK8Xq+ikh2g2/vs5VJc6o2rM8GI9iY8yIg bcFOsaACuinE58DZduuSBZmmhSy7U1W2jK1ZeJirXgFA2wj1G9EqviE1i07k9c3AIcWK hULg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DdMr6yHg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s10si905675pge.41.2018.04.18.03.48.33; Wed, 18 Apr 2018 03:48:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DdMr6yHg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbeDRKrU (ORCPT + 99 others); Wed, 18 Apr 2018 06:47:20 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41482 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750861AbeDRKrS (ORCPT ); Wed, 18 Apr 2018 06:47:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LaLLOlfdv15O/bokhmx59IlXA5XcZ1RfdPXxHeoxk7c=; b=DdMr6yHgbzCM+NX+1bTsdyBIy fKbLM+9KprFzPp0RVME3t4Sae5zeb0y2cJIVARTxISprUwEDqtY/GvPrbUpFEUCZVijqN1u5omSLp qHQwSeveg0h633hpukj9UWxlSxX6b2OJkPhgenZi9MDiHsRh5rkXo/kAKcSfcjDA9qrrK9dla14Hu ELCiI9/utrY+eyaPnWqAyvGY5XIxcqA//VeeufxS3+hnPwxGgiGWTge5FeFBkP8Os6z45BG5SXUMA Kz0cVsyT1OJS5JahnDCZ38Oa56AEauK5UhGDH5cPF6DLmMIvNIxfMPIVlHPG/lw06Rfv/CVVkDszK t5F25Il2g==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8kcB-0004nM-Dw; Wed, 18 Apr 2018 10:47:03 +0000 Date: Wed, 18 Apr 2018 03:47:03 -0700 From: Christoph Hellwig To: Jacopo Mondi Cc: ysato@users.sourceforge.jp, dalias@libc.org, thomas.petazzoni@free-electrons.com, robin.murphy@arm.com, geert@linux-m68k.org, linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sh: mm: Fix unprotected access to struct device Message-ID: <20180418104703.GA12462@infradead.org> References: <1523972123-5700-1-git-send-email-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1523972123-5700-1-git-send-email-jacopo+renesas@jmondi.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 17, 2018 at 03:35:23PM +0200, Jacopo Mondi wrote: > With commit ce88313069c36eef80f21fd7 ("arch/sh: make the DMA mapping > operations observe dev->dma_pfn_offset") the generic DMA allocation > function on which the SH 'dma_alloc_coherent()' function relies on, > access the 'dma_pfn_offset' field of struct device. > > Unfortunately the 'dma_generic_alloc_coherent()' function is called from > several places with a NULL struct device argument, halting the CPU > during the boot process. > > This patch fixes the issue protecting access to dev->dma_pfn_offset, > with a trivial check for validity. It also passes a valid 'struct device' > in the 'platform_resource_setup_memory' function which is the main user > of 'dma_alloc_coherent()', and inserting a WARN_ON() check to make future > (and existing) bogus users of this function they're should provide a valid > 'struct device' whenever possible. Please fix those callers to not pass a NULL pointer instead.