From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754534AbcCGW7V (ORCPT ); Mon, 7 Mar 2016 17:59:21 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41397 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753577AbcCGW7J (ORCPT ); Mon, 7 Mar 2016 17:59:09 -0500 Date: Mon, 7 Mar 2016 14:59:07 -0800 From: Andrew Morton To: "Leizhen (ThunderTown)" Cc: Marek Szyprowski , Will Deacon , linux-kernel , Zefan Li , Xinwei Hu , "Tianhong Ding" , Hanjun Guo Subject: Re: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL Message-Id: <20160307145907.451d527dd34ad31424d841f6@linux-foundation.org> In-Reply-To: <56DD5B63.9050609@huawei.com> References: <1457342485-16628-1-git-send-email-thunder.leizhen@huawei.com> <56DD5B63.9050609@huawei.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Mar 2016 18:43:47 +0800 "Leizhen (ThunderTown)" wrote: > Suppose: > CONFIG_SPARSEMEM is opened. > CONFIG_DMA_API_DEBUG or CONFIG_CMA is opened. > > Then virt_to_page or phys_to_page will be called. Finally, in __pfn_to_page, __sec = __pfn_to_section(__pfn) is NULL. > So access section->section_mem_map will trigger exception. > > --------- > > #define __pfn_to_page(pfn) \ > ({ unsigned long __pfn = (pfn); \ > struct mem_section *__sec = __pfn_to_section(__pfn); \ > __section_mem_map_addr(__sec) + __pfn; \ > }) > > static inline struct page *__section_mem_map_addr(struct mem_section *section) > { > unsigned long map = section->section_mem_map; > map &= SECTION_MAP_MASK; > return (struct page *)map; > } I'm having a bit of trouble understanding this. Perhaps you could explain the bug more carefully (inclusion of an oops output would help) then we'll be in a better position to understand the proposed fix(es). Thanks.