Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751841AbcCGAmO (ORCPT ); Sun, 6 Mar 2016 19:42:14 -0500 Received: from mleia.com ([178.79.152.223]:42088 "EHLO mail.mleia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221AbcCGAmD (ORCPT ); Sun, 6 Mar 2016 19:42:03 -0500 From: Vladimir Zapolskiy To: Arnd Bergmann , Greg Kroah-Hartman Cc: Abhilash Kesavan , linux-kernel@vger.kernel.org Subject: [PATCH] misc: sram: fix check of devm_ioremap_wc() return value Date: Mon, 7 Mar 2016 02:41:56 +0200 Message-Id: <1457311316-25401-1-git-send-email-vz@mleia.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-49551924 X-CRM114-CacheID: sfid-20160307_004524_694592_E82A757E X-CRM114-Status: GOOD ( 12.29 ) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 918 Lines: 29 The devm_ioremap_wc() function returns either a valid pointer to iomem region or NULL, check for IS_ERR() is bogus. The problem was introduced by commit 0ab163ad1ea0 ("misc: sram: switch to ioremap_wc from ioremap") and it survived after the recent MMIO SRAM driver refactoring. Signed-off-by: Vladimir Zapolskiy --- drivers/misc/sram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index 736dae7..9174623 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -361,8 +361,8 @@ static int sram_probe(struct platform_device *pdev) } sram->virt_base = devm_ioremap_wc(sram->dev, res->start, size); - if (IS_ERR(sram->virt_base)) - return PTR_ERR(sram->virt_base); + if (!sram->virt_base) + return -ENOMEM; sram->pool = devm_gen_pool_create(sram->dev, ilog2(SRAM_GRANULARITY), NUMA_NO_NODE, NULL); -- 2.1.4