From patchwork Thu Jan 3 07:02:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 10746949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8298746 for ; Thu, 3 Jan 2019 06:56:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A68BB2811A for ; Thu, 3 Jan 2019 06:56:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A8C0285A9; Thu, 3 Jan 2019 06:56:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 030BA2811A for ; Thu, 3 Jan 2019 06:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729787AbfACGz7 (ORCPT ); Thu, 3 Jan 2019 01:55:59 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:46278 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729771AbfACGz7 (ORCPT ); Thu, 3 Jan 2019 01:55:59 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DA56ED55FBC52; Thu, 3 Jan 2019 14:55:50 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Thu, 3 Jan 2019 14:55:43 +0800 From: Wei Yongjun To: Ohad Ben-Cohen , Bjorn Andersson , Maxime Coquelin , Alexandre Torgue , Benjamin Gaignard CC: Wei Yongjun , , , , Subject: [PATCH -next] hwspinlock: fix return value check in stm32_hwspinlock_probe() Date: Thu, 3 Jan 2019 07:02:30 +0000 Message-ID: <1546498950-105456-1-git-send-email-weiyongjun1@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of error, the function devm_ioremap_resource() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Fixes: f24fcff1d267 ("hwspinlock: add STM32 hwspinlock device") Signed-off-by: Wei Yongjun Acked-by: Benjamin Gaignard --- drivers/hwspinlock/stm32_hwspinlock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c index 34a8e00..4418392 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -57,8 +57,8 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(&pdev->dev, res); - if (!io_base) - return -ENOMEM; + if (IS_ERR(io_base)) + return PTR_ERR(io_base); array_size = STM32_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock); hw = devm_kzalloc(&pdev->dev, sizeof(*hw) + array_size, GFP_KERNEL);