From patchwork Fri Sep 16 01:49:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 9334971 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 28894607FD for ; Fri, 16 Sep 2016 01:50:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15B4229EA8 for ; Fri, 16 Sep 2016 01:50:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07CD829EAE; Fri, 16 Sep 2016 01:50:03 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 6B0F629EA8 for ; Fri, 16 Sep 2016 01:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754557AbcIPBts (ORCPT ); Thu, 15 Sep 2016 21:49:48 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33828 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754527AbcIPBtr (ORCPT ); Thu, 15 Sep 2016 21:49:47 -0400 Received: by mail-pf0-f196.google.com with SMTP id 21so1485833pfy.1 for ; Thu, 15 Sep 2016 18:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jjZYdrUM7oqOUh/opYSY4K3q20vt6IyZirSVInuoDB4=; b=r8Wlm4nYcoTLCslvxogfmkL752YmD5kgkLbDhCfOtTF5tHhhbE5AS9Xk5f8n6RuZXS euSDhmCi7lrQEV6Iof3vmY7AJ5T95MqdEYNklPX8poOwJtV80TN22SbW5orYiuFGEbm/ qy2SYyNQDYKFL/RFxuOCZMdM5PUBigqqS1VRennyYEr2S6Kwg87eYHp52QdlTVPfaNl/ 2Nz/8vypvorvcMfc7itSf95Se2ioYpvIi6nlrDAmorlYDs3I1ieoSqvtVcGP/GbbBcPj Sc/gJESidoiSYQi/0sciqnzbHYasY1gmx6ObpUMRK30tUpplHRvLkyT9Vjp8zpqI+eBm T0Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jjZYdrUM7oqOUh/opYSY4K3q20vt6IyZirSVInuoDB4=; b=OhS5xsBJBa4MbZEbDpV7tx23DDLqH8CR/tYCD0OId54+mskQW963VpuhXaORRNViIR DX47aMFnrtekTd2h6SqeTyks+ldCeN5t3A2frETsK9B+RRwdp0fl27AR8+T9W9oD/75+ /HtsSwaAQIbSGN6wZykxNYI1Gz/kV4WZBNtFqJmMQG59WPJPfTIEp4K4glciscNELP8o NMnJNDKtLeol7Q01ot56XljJ7Ud0NvCucLs/tQBQcKghsRVvY1xwi1Tks8D1tTmsmrSA tJMzBUKN09WRitQY1anDw2tbJpBJGuMV6CL6iE5xtrCeoX48GH495udIRPwQVCpb/VZk Av9A== X-Gm-Message-State: AE9vXwO/JIi2SW81N0VdKwV+LKDn0eeIQimnCWS+/riWuB4W3WYRNr1MYbyfaswxA1mBDw== X-Received: by 10.98.100.1 with SMTP id y1mr5434677pfb.169.1473990587047; Thu, 15 Sep 2016 18:49:47 -0700 (PDT) Received: from localhost.localdomain.localdomain (ec2-52-192-197-227.ap-northeast-1.compute.amazonaws.com. [52.192.197.227]) by smtp.gmail.com with ESMTPSA id s7sm47764388pfk.11.2016.09.15.18.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2016 18:49:46 -0700 (PDT) From: Wei Yongjun To: Matt Mackall , Herbert Xu , Corentin LABBE , PrasannaKumar Muralidharan Cc: Wei Yongjun , linux-crypto@vger.kernel.org Subject: [PATCH -next] hwrng: amd - Fix return value check in mod_init() Date: Fri, 16 Sep 2016 01:49:41 +0000 Message-Id: <1473990581-18602-1-git-send-email-weiyj.lk@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Yongjun In case of error, the function devm_kzalloc() or devm_ioport_map() return NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. Fixes: 31b2a73c9c5f ("hwrng: amd - Migrate to managed API") Signed-off-by: Wei Yongjun --- drivers/char/hw_random/amd-rng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c index 4dbc5aa..4a99ac7 100644 --- a/drivers/char/hw_random/amd-rng.c +++ b/drivers/char/hw_random/amd-rng.c @@ -149,8 +149,8 @@ static int __init mod_init(void) return -EIO; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (IS_ERR(priv)) - return PTR_ERR(priv); + if (!priv) + return -ENOMEM; if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET, PMBASE_SIZE, DRV_NAME)) { @@ -161,9 +161,9 @@ static int __init mod_init(void) priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET, PMBASE_SIZE); - if (IS_ERR(priv->iobase)) { + if (!priv->iobase) { pr_err(DRV_NAME "Cannot map ioport\n"); - return PTR_ERR(priv->iobase); + return -ENOMEM; } amd_rng.priv = (unsigned long)priv;