Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp371841rwe; Thu, 25 Aug 2022 01:42:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR56nf5prRDtfMyAMkJTG0iEmDyt6yzSlif8OA/xR/6dmPgc3sBg9GtEmh3hlrsvB+mEl2a9 X-Received: by 2002:a17:902:b483:b0:170:a89f:32b3 with SMTP id y3-20020a170902b48300b00170a89f32b3mr2928749plr.149.1661416936127; Thu, 25 Aug 2022 01:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661416936; cv=none; d=google.com; s=arc-20160816; b=lCWPPGUiEnQKhpqiSampVx1Mm9R5keQmbgJQcsB53axTCEYgXR1DArcY55iW6oRnX0 ifRb0qgDHyK8rwE3ND6zAuemQrqH6i6WJ0Z/58VTyaoPMgc23VINOfOJFVly0hI8Vphk WM2TvSA20v8+mSdIg7Xq0W5xGf4l4Nc+3lhHqzwMBYb8cpmzzhuOjuE/qQ6NlTRURkhP i2MSXFTv5Rb4c2wwet9u0VldZPkzpip96+Yk69ocuUk1YHSAJpqmDsfNHiULCEgD03Xc BPQZI+tGG7SYqh2E/OUMRZJzA7thZ9yOvBC3t+yONpGxA/Y/19JWVRCg5U8xFeKFawhs sYTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mvuAywXaPVouClPGD+sz6YU/8+Vt/7XBuqPmgR+r4DI=; b=u6nj4cs/WQDd6sysExl+wQq2mexuqJxtzsiZUvDlUj54dzsyAag60nuG7YiRSsnVTV uF9Ws/+eUPkFOKij4MY8kAYtMceNk/YZvZjs/jIBkk9thAycGM7G6oyFhghRHBByG3re O9hKlcOip5rfz5iFrpTLVpL0LdjI8/CTTHifT6oMlIxzuaK1Nagoem7MVLPAZHJYgpqc qPLGv7+ScH1Ul3mvqKX+D3JkiU7fT/Vf5zCt7o4InG/JZAtFgnUOcdYFXUDUUbE2Zv00 4fp3HbNFFUyGy1lg6UQOOWzOayAnqhu7ycokb4BSmfF8EFHKQYp4x2M58tofmtHNrGSL /R9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a170903024600b0016bea2a8b16si20937838plh.364.2022.08.25.01.41.57; Thu, 25 Aug 2022 01:42:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238314AbiHYIlu (ORCPT + 99 others); Thu, 25 Aug 2022 04:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236760AbiHYIlo (ORCPT ); Thu, 25 Aug 2022 04:41:44 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5380792C2; Thu, 25 Aug 2022 01:41:42 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MCxH30HPQzGpqB; Thu, 25 Aug 2022 16:39:59 +0800 (CST) Received: from dggphis33418.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 25 Aug 2022 16:41:39 +0800 From: Gaosheng Cui To: , , CC: , Subject: [PATCH -next 1/2] crypto: api - Fix IS_ERR() vs NULL check Date: Thu, 25 Aug 2022 16:41:37 +0800 Message-ID: <20220825084138.1881954-2-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220825084138.1881954-1-cuigaosheng1@huawei.com> References: <20220825084138.1881954-1-cuigaosheng1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The crypto_alloc_test_larval() will return null if manager is disabled, it may not return error pointers, so using IS_ERR_OR_NULL() to check the return value to fix this. The __crypto_register_alg() will return null if manager is disabled, it may not return error pointers, so using IS_ERR_OR_NULL() to check the return value to fix this. Fixes: cad439fc040e ("crypto: api - Do not create test larvals if manager is disabled") Signed-off-by: Gaosheng Cui --- crypto/algapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/algapi.c b/crypto/algapi.c index 5c69ff8e8fa5..5a080b8aaa11 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -283,7 +283,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) } larval = crypto_alloc_test_larval(alg); - if (IS_ERR(larval)) + if (IS_ERR_OR_NULL(larval)) goto out; list_add(&alg->cra_list, &crypto_alg_list); @@ -651,7 +651,7 @@ int crypto_register_instance(struct crypto_template *tmpl, inst->alg.cra_flags |= (fips_internal & CRYPTO_ALG_FIPS_INTERNAL); larval = __crypto_register_alg(&inst->alg); - if (IS_ERR(larval)) + if (IS_ERR_OR_NULL(larval)) goto unlock; else if (larval) larval->test_started = true; -- 2.25.1