From patchwork Mon Mar 7 09:21:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 63639 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1335655lbc; Mon, 7 Mar 2016 01:23:42 -0800 (PST) X-Received: by 10.98.72.213 with SMTP id q82mr2139962pfi.164.1457342622075; Mon, 07 Mar 2016 01:23:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si17064989pfj.121.2016.03.07.01.23.41; Mon, 07 Mar 2016 01:23:42 -0800 (PST) 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; 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 S1752549AbcCGJXk (ORCPT + 30 others); Mon, 7 Mar 2016 04:23:40 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:49418 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752169AbcCGJXb (ORCPT ); Mon, 7 Mar 2016 04:23:31 -0500 Received: from 172.24.1.137 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.137]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DCX20048; Mon, 07 Mar 2016 17:23:26 +0800 (CST) Received: from localhost (10.177.23.164) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Mon, 7 Mar 2016 17:23:18 +0800 From: Zhen Lei To: Andrew Morton , Marek Szyprowski , Will Deacon , linux-kernel CC: Zefan Li , Xinwei Hu , "Tianhong Ding" , Hanjun Guo , Zhen Lei Subject: [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL Date: Mon, 7 Mar 2016 17:21:25 +0800 Message-ID: <1457342485-16628-1-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.56DD4890.0034, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ae64ce75d02adbae51296236b25efb11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do this to keep consistent with kfree, which tolerate ptr is NULL. Signed-off-by: Zhen Lei --- include/linux/dma-mapping.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.5.0 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 75857cd..fdd4294 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -402,7 +402,10 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size, static inline void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle) { - return dma_free_attrs(dev, size, cpu_addr, dma_handle, NULL); + if (unlikely(!cpu_addr)) + return; + + dma_free_attrs(dev, size, cpu_addr, dma_handle, NULL); } static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,