Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1265876imi; Fri, 22 Jul 2022 23:52:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1svHB6VSZeiymryThIUs1S7XXUWFcfe5bUg/dCIXUjJFUw34b/eFmvIrSZVeifUFSIHJVUe X-Received: by 2002:a17:906:cc4a:b0:72b:863e:ef7c with SMTP id mm10-20020a170906cc4a00b0072b863eef7cmr2548331ejb.686.1658559125399; Fri, 22 Jul 2022 23:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658559125; cv=none; d=google.com; s=arc-20160816; b=twCyv4iKJbgxfGRRYBkwLiSmqYU71XM/m8IlsYUEb1s3xCASTCZc0xqzCJ+puU+jNW QargcnFxLJh+/gKIqlCsQzJnyq5RjmsP8MW2UvzB9twr/IDFAKFZFsvx+DeJ1xK6iZAH xdu87ZWiwT1q3LBdrkAMywmF6k1+EI7u3gmM8F3qPG3bCbSdrye8p7qyOc7mdywK3pWg kHuTRmLsWNalr3RrFvzIedZj2aqxHDIUodPi08Tq+odGZpvrC2zsz178zlTZFAQIQ6eB G21x9r38TN+qIZYKoEzRsQbFYrlhjEi9gszMgdCx1cHDA0JA4zEiw8tjQXVszb//SBqP RoCA== 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=kucPnkJPET0vErhB73+JEC1LgKSF0wQdv8SoTfgnP4A=; b=sEEB56/RLZLWUYFaC7fkUMFfx3CWwO56YY6YkL4YiNOVSPa6Bf7PpoIRHcD/Xr9KZc 07uz7DmG15UCGT2RGzIy+fWaeiMJf4CzBJr2Oq2WcGU+PklwYT15jgIN9C2l08ifHbHP Ds671nyPel5rVLVUyy5CZyDVbA+/6m6XasIMbiJ4XJwOBQf11e2D5Oo0/Zw3j6fkz+7M /QUI6Mblj/7Ck6freiEe/pTu/9uB3lm9qyE2jBR0YyUPaRayPECSF6VlpsQj+ajYi1Wg 4xyUapcqOffbu2NkLpu+Fg4mGgcLdlebETjmmXAl6AG/a/foCjkRAe05376CDNC5lUZS 06mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="BJPrKQh/"; 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 k3-20020aa7c383000000b0043bb9f01aaesi7619290edq.335.2022.07.22.23.51.40; Fri, 22 Jul 2022 23:52:05 -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="BJPrKQh/"; 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 S235228AbiGWGlu (ORCPT + 99 others); Sat, 23 Jul 2022 02:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbiGWGls (ORCPT ); Sat, 23 Jul 2022 02:41:48 -0400 Received: from mail-m974.mail.163.com (mail-m974.mail.163.com [123.126.97.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D17464E11; Fri, 22 Jul 2022 23:41:46 -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=kucPn kJPET0vErhB73+JEC1LgKSF0wQdv8SoTfgnP4A=; b=BJPrKQh/vhuRZ+NC2pWDR CdpiBHLOLW/NSN7g8tEdAnk1FGze9taU8hIvGb6YjmsJLY5wQCT+MWbVm+X61YOe AEJqFQv9B92eAreMcQj1qzrh847UFCVf43Gq+jNbpSeKj3x23XKtbJqLP6egnjwJ fBIl3GTzD8PRkQ8vmLc3dI= Received: from localhost.localdomain (unknown [123.58.221.99]) by smtp4 (Coremail) with SMTP id HNxpCgCX5ITfl9titVQzQQ--.40765S2; Sat, 23 Jul 2022 14:40:32 +0800 (CST) From: williamsukatube@163.com To: jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.smart@broadcom.com, dick.kennedy@broadcom.com, William Dean , Hacash Robot Subject: [PATCH] scsi: lpfc: check the return value of alloc_workqueue() Date: Sat, 23 Jul 2022 14:40:27 +0800 Message-Id: <20220723064027.2956623-1-williamsukatube@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HNxpCgCX5ITfl9titVQzQQ--.40765S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtFWxCF4UXF4kAFykZw1xuFg_yoWDAwb_ua y8ZF1xXws5GF1xAasrJr43Z3sI9r48XFnxu3Z0qryrCr4xZF1kWFs8WFn8X3yUArn5JFyD Ga1rX3y0yr13ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5uwZ7UUUUU== X-Originating-IP: [123.58.221.99] X-CM-SenderInfo: xzlozx5dpv3yxdwxuvi6rwjhhfrp/xtbBiAFHg1aECKfLXAAAsn 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 lpfc_sli4_driver_resource_setup() 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: 3cee98db2610f ("scsi: lpfc: Fix crash on driver unload in wq free") Reported-by: Hacash Robot Signed-off-by: William Dean --- drivers/scsi/lpfc/lpfc_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 750dd1e9f2cc..8e9594f4ed16 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -7958,6 +7958,8 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) /* The lpfc_wq workqueue for deferred irq use */ phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); + if (!phba->wq) + return -ENOMEM; /* * Initialize timers used by driver -- 2.25.1