Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752137AbdHHNno (ORCPT ); Tue, 8 Aug 2017 09:43:44 -0400 Received: from m12-14.163.com ([220.181.12.14]:43387 "EHLO m12-14.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752082AbdHHNnm (ORCPT ); Tue, 8 Aug 2017 09:43:42 -0400 From: Pan Bian To: Tom Lendacky , Gary Hook , Herbert Xu , "David S. Miller" Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: crypto: ccp: use dma_mapping_error to check map error Date: Tue, 8 Aug 2017 21:42:47 +0800 Message-Id: <1502199767-2578-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DsCowADn93Phv4lZPyfhSA--.8468S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Gry8Wr4Uur47try7uFyDJrb_yoW3twcE9r WUu3WxGws5Ww1293W2grWrZr1a9rWrZF4kCr1UtrnIkryrCFs7W34IvFnrJr1xZrW7JFWD CF43ZFy3ZFnrZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnQyCJUUUUU== X-Originating-IP: [106.120.213.62] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBZwMucletmx47YQAAsd Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 801 Lines: 25 The return value of dma_map_single() should be checked by dma_mapping_error(). However, in function ccp_init_dm_workarea(), its return value is checked against NULL, which could result in failures. Signed-off-by: Pan Bian --- drivers/crypto/ccp/ccp-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index c0dfdac..ca83d19 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -168,7 +168,7 @@ static int ccp_init_dm_workarea(struct ccp_dm_workarea *wa, wa->dma.address = dma_map_single(wa->dev, wa->address, len, dir); - if (!wa->dma.address) + if (dma_mapping_error(wa->dev, wa->dma.address)) return -ENOMEM; wa->dma.length = len; -- 1.9.1