Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1278226imi; Sat, 23 Jul 2022 00:22:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1spwZladu2vL2sAmA/TKIGmYyUn5orU7rW8bjvwDyH3Yurddk1O8Cxr5s++jyeCokEex2NV X-Received: by 2002:a05:6402:3705:b0:43a:214b:5f40 with SMTP id ek5-20020a056402370500b0043a214b5f40mr3178456edb.83.1658560936017; Sat, 23 Jul 2022 00:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658560936; cv=none; d=google.com; s=arc-20160816; b=GC3cgthWbVeIGE53D8ycD8rsMXVbLGKtlxeowqpTEZvMbLr73j/LptRiqppyaJ6lUW GsvUeo60SeDWH8c35Gg4XHbxjnEHV5qAVcbsfENIhkhRrQqD3fo9JG1Vl0bgEQD77vbf VLe8e+9SXqXew73sX8Ft90gKXnDl1JLAdJocJ8IWi/1TUUdmRqi9IQls5BUXFd6JWiXZ O9tJt5/AgHhB0K+hYO3Z/oWFhT2Y97XoAM5hadN010YfphUwHOma3MjNggXyrGUit9e3 YuZflr6QizMBKJqU6tR6FdQGwvoix5PnsnEUAzBHaf02O7JHb2BRNTLhCIzhMNYSuvJJ OkxA== 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:dkim-signature; bh=KZDSpPbIpEXdoyPYRgzx3dJeJEfWOtuL5cZbKBw/Vis=; b=RNu4VDpZ6MkwjBf+C3Z6gp4Fd2ZTb1/DRL5coIWFcRMfZFPnh5+JQKclpbdcCKUd+9 IL/+FwWW68N0kQ1u+2cPyVGlSPUDxwk9x03OKGDveg0dl1mBjVK4MrwMWGCyTWNUZMK9 JFaPAgbLx6CfbEV6iipMULklbPYSTyvpNwrY4Fg9DIWCzNtMHjseViqvZMSIYysVoeYw m0O5Jc1ybz4rzyzch3CpjETmBwLhJdYW4ZdigEEUQ0qaQVILczDgyty1p5qZ3b7Ysd88 dKcZwz191MLYZXFCms3pmCHJh6l7yrgqAIqeomxdTMGUwdGlYNnt3tSsZ3FigiWAs4Ji Hx5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=VLu6Z0eN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020aa7c0c8000000b0043a0ab0aa07si7492220edp.263.2022.07.23.00.21.48; Sat, 23 Jul 2022 00:22:16 -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; dkim=pass header.i=@163.com header.s=s110527 header.b=VLu6Z0eN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236019AbiGWGpE (ORCPT + 99 others); Sat, 23 Jul 2022 02:45:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235993AbiGWGpB (ORCPT ); Sat, 23 Jul 2022 02:45:01 -0400 Received: from mail-m972.mail.163.com (mail-m972.mail.163.com [123.126.97.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B36067CBD; Fri, 22 Jul 2022 23:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=KZDSp PbIpEXdoyPYRgzx3dJeJEfWOtuL5cZbKBw/Vis=; b=VLu6Z0eNZG3SkGB4YFD9l dZn1eUrxVQXRPfjHRtru5bJ45/pksdesKPaXQFYBul9lfHN3Q5OCIDWoPHYE+GWR 7Eyc+d8VldlaCUEi8U1y9oLZ/7l/fbbqYfkssTYxCX0l+8OE3vmlWqgPP8cv9wFg u0OY7qsb6aDG4ISCYSRdKk= Received: from localhost.localdomain (unknown [123.58.221.99]) by smtp2 (Coremail) with SMTP id GtxpCgDnRemdmNtiRiIVQw--.40677S2; Sat, 23 Jul 2022 14:43:43 +0800 (CST) From: williamsukatube@163.com To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kishon@ti.com, lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com, William Dean , Hacash Robot Subject: [PATCH] PCI: endpoint: check the return value of alloc_workqueue() Date: Sat, 23 Jul 2022 14:43:39 +0800 Message-Id: <20220723064339.2957069-1-williamsukatube@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgDnRemdmNtiRiIVQw--.40677S2 X-Coremail-Antispam: 1Uf129KBjvJXoWrtFWxXr1DWr1DKF18CF1fCrg_yoW8Jr18pr Z3Cry0yrW8tw4UGF45Xr4kAr9xAa1qg347ZryfWw4ava1xGFyrK3ykta43tFZrGrWUXw4r tFZ8Xa4aqF1UAr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bF9N3UUUUU= X-Originating-IP: [123.58.221.99] X-CM-SenderInfo: xzlozx5dpv3yxdwxuvi6rwjhhfrp/1tbiNx9Hg1WBo2yi3QAAsI X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 From: William Dean The function alloc_workqueue() in epf_ntb_init() can fail, but there is no check of its return value. To fix this bug, its return value should be checked with new error handling code. Fixes: 8b821cf761503 ("PCI: endpoint: Add EP function driver to provide NTB functionality") Reported-by: Hacash Robot Signed-off-by: William Dean --- drivers/pci/endpoint/functions/pci-epf-ntb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c index 9a00448c7e61..41d85591cd1e 100644 --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c @@ -2124,6 +2124,11 @@ static int __init epf_ntb_init(void) kpcintb_workqueue = alloc_workqueue("kpcintb", WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); + if (!kpcintb_workqueue) { + pr_err("Failed to alloc kpcintb workqueue\n"); + return -ENOMEM; + } + ret = pci_epf_register_driver(&epf_ntb_driver); if (ret) { destroy_workqueue(kpcintb_workqueue); -- 2.25.1