Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S980218AbdDYDMA (ORCPT ); Mon, 24 Apr 2017 23:12:00 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34931 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S980182AbdDYDLy (ORCPT ); Mon, 24 Apr 2017 23:11:54 -0400 From: Wei Yongjun To: Greg Kroah-Hartman , Thierry Escande Cc: Wei Yongjun , linux-kernel@vger.kernel.org Subject: [PATCH -next] firmware: google memconsole: Fix return value check in platform_memconsole_init() Date: Tue, 25 Apr 2017 03:11:48 +0000 Message-Id: <20170425031148.9310-1-weiyj.lk@gmail.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1007 Lines: 26 From: Wei Yongjun In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Fixes: d384d6f43d1e ("firmware: google memconsole: Add coreboot support") Signed-off-by: Wei Yongjun --- drivers/firmware/google/memconsole-coreboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/google/memconsole-coreboot.c b/drivers/firmware/google/memconsole-coreboot.c index 2121014..0271111 100644 --- a/drivers/firmware/google/memconsole-coreboot.c +++ b/drivers/firmware/google/memconsole-coreboot.c @@ -95,8 +95,8 @@ static int __init platform_memconsole_init(void) struct platform_device *pdev; pdev = platform_device_register_simple("memconsole", -1, NULL, 0); - if (pdev == NULL) - return -ENODEV; + if (IS_ERR(pdev)) + return PTR_ERR(pdev); platform_driver_register(&memconsole_driver);