Received: by 2002:a05:6a10:87d6:0:0:0:0 with SMTP id g22csp833393pxr; Mon, 11 Apr 2022 08:19:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7s/AAhTw4uNZMWA40HIeWLzyXg44H1Zz1vWVQQ42RBSUqWyLuMj3L9J6Ty6VW+hnTRBeb X-Received: by 2002:a17:906:58d6:b0:6da:bc08:af7 with SMTP id e22-20020a17090658d600b006dabc080af7mr30080269ejs.537.1649690347287; Mon, 11 Apr 2022 08:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649690347; cv=none; d=google.com; s=arc-20160816; b=EdVcWGy5Grkrae1VuOaAdaEClwHGx/jbyB8aoZ0jGoe3HzG72OMJEqXBhNMnY8vlw6 2KmAgBd893MLWbcgqptfvLSI+4Q9A73AbYm6su2UUrMW6QT0Yn+mw7z4nrX7xasze5ii oYQvzWDgi+0vDEqBJij+A1TYVhHgVLuO7YpW2iY5Rx3dj5T9zaMd6UJ8rvntatG6Owsl E95wQ9dsp9hfTFw9LsvgXvRCTmp+6s3Ykr6sKtRH+k6JCbOsiLyOQTnUhsSoOwDpDTMp dy/odteunUwb1gWWAgNxMGOceSEX/qGC6GG9h1BW9WH+vfV8JuIZejLETNvP8ndIlrJ3 PyQw== 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 :message-id:date:subject:cc:to:from; bh=+3G1T1mPLDOYuBlnG6WfjcWyRPh3E2BC7LDFQ2sS0PI=; b=Rk29CX3EiL1G6mnvQWo3qoHRMgPXzE9zOz+VsqIafLSwI1Rac2pSKCuZU1/nMKttWp LakibBsOcvI9ngWc1I2s4d2zim3wbRj0w8kvUnNzcu1aUDb2kziF1jan9e8TYWReUM8K bXUql5+oHvgNvG9N4gxBH/OEku50CNEacQOBuH7p112BQt4RXycKEAIQbsJyjRSvv9wg GBT0bDHFPExQ1zd5KRKtP7z0dTvCn0GtJGIJf81pF260Xs0CJ4rZB0NyRETs9p8EMgX3 sJIDCI5PRHl8EgmBo/zS0BxGlB4SnSCv2Iv1T6jZTARCYJHs92KbPn94UYlf1BkC/ZYL yADw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 h2-20020a1709066d8200b006e85953eb12si6562910ejt.347.2022.04.11.08.18.40; Mon, 11 Apr 2022 08:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S244759AbiDKLFz (ORCPT + 99 others); Mon, 11 Apr 2022 07:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244385AbiDKLFy (ORCPT ); Mon, 11 Apr 2022 07:05:54 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22AA1C47 for ; Mon, 11 Apr 2022 04:03:39 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KcQrm0BnqzFpnD; Mon, 11 Apr 2022 19:01:12 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Apr 2022 19:03:30 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Apr 2022 19:03:30 +0800 From: Yang Yingliang To: CC: , Subject: [PATCH -next] virt: sevguest: Fix return value check in alloc_shared_pages() Date: Mon, 11 Apr 2022 19:12:13 +0800 Message-ID: <20220411111213.1477853-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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-kernel@vger.kernel.org If alloc_pages() fails, it returns NULL pointer, replaces IS_ERR() check with NULL pointer check. Fixes: fce96cf04430 ("virt: Add SEV-SNP guest driver") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/virt/coco/sevguest/sevguest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virt/coco/sevguest/sevguest.c b/drivers/virt/coco/sevguest/sevguest.c index 15afb6ce8d19..aaa6134d1d40 100644 --- a/drivers/virt/coco/sevguest/sevguest.c +++ b/drivers/virt/coco/sevguest/sevguest.c @@ -581,7 +581,7 @@ static void *alloc_shared_pages(size_t sz) int ret; page = alloc_pages(GFP_KERNEL_ACCOUNT, get_order(sz)); - if (IS_ERR(page)) + if (!page) return NULL; ret = set_memory_decrypted((unsigned long)page_address(page), npages); -- 2.25.1