From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754470AbcGVNz5 (ORCPT ); Fri, 22 Jul 2016 09:55:57 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34936 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754021AbcGVNzz (ORCPT ); Fri, 22 Jul 2016 09:55:55 -0400 From: Wei Yongjun To: Matt Porter , Alexandre Bounine Cc: Wei Yongjun , linux-kernel@vger.kernel.org Subject: [PATCH -next] rapidio/rio_cm: fix return value check in riocm_init() Date: Fri, 22 Jul 2016 21:55:49 +0800 Message-Id: <1469195749-17032-1-git-send-email-weiyj.lk@gmail.com> X-Mailer: git-send-email 2.7.4 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 In case of error, the function class_create() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun --- drivers/rapidio/rio_cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c index 0683e5e..cecc15a 100644 --- a/drivers/rapidio/rio_cm.c +++ b/drivers/rapidio/rio_cm.c @@ -2288,9 +2288,9 @@ static int __init riocm_init(void) /* Create device class needed by udev */ dev_class = class_create(THIS_MODULE, DRV_NAME); - if (!dev_class) { + if (IS_ERR(dev_class)) { riocm_error("Cannot create " DRV_NAME " class"); - return -EINVAL; + return PTR_ERR(dev_class); } ret = alloc_chrdev_region(&dev_number, 0, 1, DRV_NAME);