Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp325659pxb; Mon, 16 Aug 2021 06:22:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPOa44UJgdQz7EVUB6TfABZVtP8GE+d52VWGqulSIpFwYauHWnbwbfq5xCKo97ItHGwQ6z X-Received: by 2002:a17:906:d20a:: with SMTP id w10mr16472473ejz.426.1629120140869; Mon, 16 Aug 2021 06:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629120140; cv=none; d=google.com; s=arc-20160816; b=Ey6A/gdgYTvjFbSzbaYQBlkYXOXj0bP8V6U9ufpq9oxo46VLlCnbEUzMIUL/QZPg9t NHmORal1EhaDBn8NYkS45c2qvaLlnCclKex9jdNdnz9tcs/Eq6ZS7eqWIKdOri/fnqtf V3zuoSsDt2S9v9Xw0lZcJpGaP5BEwEx9KprBCM9lFg3ihRcuqB4JsGJ4HUT1fmTPendN OolguxF2XTa2/YD+HaVZVTDmpB3QmOo57teSHXBhIXn9806Sv0HdNg+hWR0DhI4/tPXX yNb0OiTkcV+H4LeQSyE8TAsbwwRjkE2zuUMwCLZrl4CH5l8iTu4KDQmOvH0CFd5TYKjN soCA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=emB1FVN5C1YeBctdqXdqKZE8s6Gf//GZEoBIkw4V+iU=; b=mUmQTVlGGyPOa3LMRSR+FFEcwNurI4tEBuMyAycUWx6dwUFUq5NvKSsWTOTQkapw0w XQpX5Z3z7sxt6r1PQYp1Mj7159aEmRbDo4cSjb4v0dPNCaZkUx4Sxs41lKYefnsBQFA9 zjMB0RJ5dR5IRiiueGLlNfGkoMqPgCQTMOwymDioePR6J14P8uSDyhZ6IfTTw7fHL3Mp 7rbFe/MK6amVgD5XO21WsOWhcKs3iFqNb2ygGb85Ggqf9TJx5BQuPR44d1PiNv4op03s drpN99tFRHQjGJoqiD5N/crFUSamPQVNhW0cxXIf8BzLroVCGKReVrocUml8qOtjGOPT ogyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o2RmOzrj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si10005942edr.59.2021.08.16.06.21.58; Mon, 16 Aug 2021 06:22:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o2RmOzrj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236809AbhHPNU3 (ORCPT + 99 others); Mon, 16 Aug 2021 09:20:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:37182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237648AbhHPNM4 (ORCPT ); Mon, 16 Aug 2021 09:12:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8A09D610A0; Mon, 16 Aug 2021 13:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629119424; bh=HCVBo34rZ/yPtcPcx4BgRiYBIYx0qGks7m6OosID9CA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o2RmOzrj7qkvaQ71enUPburYXmMEVDlWaARSCbsvjePo5fIcoMGOW8/p4+ZMRqgLP tMXlbIfAMAxo/JrYw5hOiDec8iwOQFMTMS1hhS5rzsI/BLecAzPmt9URX8pU1ZkAiZ WhgTt+RKi2H+I8Gvez5gb4pzegsXgBvUoC8yOI8w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Smart , "Ewan D. Milne" , "Martin K. Petersen" Subject: [PATCH 5.13 020/151] scsi: lpfc: Move initialization of phba->poll_list earlier to avoid crash Date: Mon, 16 Aug 2021 15:00:50 +0200 Message-Id: <20210816125444.739768241@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816125444.082226187@linuxfoundation.org> References: <20210816125444.082226187@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ewan D. Milne commit 9977d880f7a3c233db9165a75a3a14defc2a4aee upstream. The phba->poll_list is traversed in case of an error in lpfc_sli4_hba_setup(), so it must be initialized earlier in case the error path is taken. [ 490.030738] lpfc 0000:65:00.0: 0:1413 Failed to init iocb list. [ 490.036661] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 [ 490.044485] PGD 0 P4D 0 [ 490.047027] Oops: 0000 [#1] SMP PTI [ 490.050518] CPU: 0 PID: 7 Comm: kworker/0:1 Kdump: loaded Tainted: G I --------- - - 4.18. [ 490.060511] Hardware name: Dell Inc. PowerEdge R440/0WKGTH, BIOS 1.4.8 05/22/2018 [ 490.067994] Workqueue: events work_for_cpu_fn [ 490.072371] RIP: 0010:lpfc_sli4_cleanup_poll_list+0x20/0xb0 [lpfc] [ 490.078546] Code: cf e9 04 f7 fe ff 0f 1f 40 00 0f 1f 44 00 00 41 57 49 89 ff 41 56 41 55 41 54 4d 8d a79 [ 490.097291] RSP: 0018:ffffbd1a463dbcc8 EFLAGS: 00010246 [ 490.102518] RAX: 0000000000008200 RBX: ffff945cdb8c0000 RCX: 0000000000000000 [ 490.109649] RDX: 0000000000018200 RSI: ffff9468d0e16818 RDI: 0000000000000000 [ 490.116783] RBP: ffff945cdb8c1740 R08: 00000000000015c5 R09: 0000000000000042 [ 490.123915] R10: 0000000000000000 R11: ffffbd1a463dbab0 R12: ffff945cdb8c25c0 [ 490.131049] R13: 00000000fffffff4 R14: 0000000000001800 R15: ffff945cdb8c0000 [ 490.138182] FS: 0000000000000000(0000) GS:ffff9468d0e00000(0000) knlGS:0000000000000000 [ 490.146267] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 490.152013] CR2: 0000000000000000 CR3: 000000042ca10002 CR4: 00000000007706f0 [ 490.159146] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 490.166277] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 490.173409] PKRU: 55555554 [ 490.176123] Call Trace: [ 490.178598] lpfc_sli4_queue_destroy+0x7f/0x3c0 [lpfc] [ 490.183745] lpfc_sli4_hba_setup+0x1bc7/0x23e0 [lpfc] [ 490.188797] ? kernfs_activate+0x63/0x80 [ 490.192721] ? kernfs_add_one+0xe7/0x130 [ 490.196647] ? __kernfs_create_file+0x80/0xb0 [ 490.201020] ? lpfc_pci_probe_one_s4.isra.48+0x46f/0x9e0 [lpfc] [ 490.206944] lpfc_pci_probe_one_s4.isra.48+0x46f/0x9e0 [lpfc] [ 490.212697] lpfc_pci_probe_one+0x179/0xb70 [lpfc] [ 490.217492] local_pci_probe+0x41/0x90 [ 490.221246] work_for_cpu_fn+0x16/0x20 [ 490.224994] process_one_work+0x1a7/0x360 [ 490.229009] ? create_worker+0x1a0/0x1a0 [ 490.232933] worker_thread+0x1cf/0x390 [ 490.236687] ? create_worker+0x1a0/0x1a0 [ 490.240612] kthread+0x116/0x130 [ 490.243846] ? kthread_flush_work_fn+0x10/0x10 [ 490.248293] ret_from_fork+0x35/0x40 [ 490.251869] Modules linked in: lpfc(+) xt_CHECKSUM ipt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4i [ 490.332609] CR2: 0000000000000000 Link: https://lore.kernel.org/r/20210809150947.18104-1-emilne@redhat.com Fixes: 93a4d6f40198 ("scsi: lpfc: Add registration for CPU Offline/Online events") Cc: stable@vger.kernel.org Reviewed-by: James Smart Signed-off-by: Ewan D. Milne Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/lpfc/lpfc_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -13091,6 +13091,8 @@ lpfc_pci_probe_one_s4(struct pci_dev *pd if (!phba) return -ENOMEM; + INIT_LIST_HEAD(&phba->poll_list); + /* Perform generic PCI device enabling operation */ error = lpfc_enable_pci_dev(phba); if (error) @@ -13225,7 +13227,6 @@ lpfc_pci_probe_one_s4(struct pci_dev *pd /* Enable RAS FW log support */ lpfc_sli4_ras_setup(phba); - INIT_LIST_HEAD(&phba->poll_list); timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp);