Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751073AbcCFBVh (ORCPT ); Sat, 5 Mar 2016 20:21:37 -0500 Received: from mleia.com ([178.79.152.223]:41514 "EHLO mail.mleia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbcCFBVe (ORCPT ); Sat, 5 Mar 2016 20:21:34 -0500 From: Vladimir Zapolskiy To: Jassi Brar Cc: Lee Jones , linux-kernel@vger.kernel.org Subject: [PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource() Date: Sun, 6 Mar 2016 03:21:27 +0200 Message-Id: <1457227287-3039-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-20160306_012455_219695_859CC9D8 X-CRM114-Status: GOOD ( 12.09 ) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1011 Lines: 29 The change fixes potential oops while accessing iomem on invalid address, if devm_ioremap_resource() fails due to some reason. The devm_ioremap_resource() function returns ERR_PTR() and never returns NULL, which makes useless a following check for NULL. Signed-off-by: Vladimir Zapolskiy Fixes: 9ef4546cbd7e ("mailbox: Add support for ST's Mailbox IP") --- drivers/mailbox/mailbox-sti.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c index 2394cfe..a334db5 100644 --- a/drivers/mailbox/mailbox-sti.c +++ b/drivers/mailbox/mailbox-sti.c @@ -430,8 +430,8 @@ static int sti_mbox_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mdev->base = devm_ioremap_resource(&pdev->dev, res); - if (!mdev->base) - return -ENOMEM; + if (IS_ERR(mdev->base)) + return PTR_ERR(mdev->base); ret = of_property_read_string(np, "mbox-name", &mdev->name); if (ret) -- 2.1.4