scsi: fcoe: Fix transport not deattached when fcoe_if_init() fails

Message ID 20221115092442.133088-1-chenzhongjin@huawei.com
State New
Headers
Series scsi: fcoe: Fix transport not deattached when fcoe_if_init() fails |

Commit Message

Chen Zhongjin Nov. 15, 2022, 9:24 a.m. UTC
  fcoe_init() calls fcoe_transport_attach(&fcoe_sw_transport), but when
fcoe_if_init() fails, &fcoe_sw_transport is not detached and leave freed
&fcoe_sw_transport on list fcoe_transports, which causes panic when
reinserting module.

 BUG: unable to handle page fault for address: fffffbfff82e2213
 RIP: 0010:fcoe_transport_attach+0xe1/0x230 [libfcoe]
 Call Trace:
  <TASK>
  do_one_initcall+0xd0/0x4e0
  load_module+0x5eee/0x7210
  ...

Fixes: 78a582463c1e ("[SCSI] fcoe: convert fcoe.ko to become an fcoe transport provider driver")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
---
 drivers/scsi/fcoe/fcoe.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Martin K. Petersen Nov. 26, 2022, 12:21 a.m. UTC | #1
Chen,

> fcoe_init() calls fcoe_transport_attach(&fcoe_sw_transport), but when
> fcoe_if_init() fails, &fcoe_sw_transport is not detached and leave freed
> &fcoe_sw_transport on list fcoe_transports, which causes panic when
> reinserting module.

Applied to 6.2/scsi-staging, thanks!
  
Martin K. Petersen Dec. 1, 2022, 3:45 a.m. UTC | #2
On Tue, 15 Nov 2022 17:24:42 +0800, Chen Zhongjin wrote:

> fcoe_init() calls fcoe_transport_attach(&fcoe_sw_transport), but when
> fcoe_if_init() fails, &fcoe_sw_transport is not detached and leave freed
> &fcoe_sw_transport on list fcoe_transports, which causes panic when
> reinserting module.
> 
>  BUG: unable to handle page fault for address: fffffbfff82e2213
>  RIP: 0010:fcoe_transport_attach+0xe1/0x230 [libfcoe]
>  Call Trace:
>   <TASK>
>   do_one_initcall+0xd0/0x4e0
>   load_module+0x5eee/0x7210
>   ...
> 
> [...]

Applied to 6.2/scsi-queue, thanks!

[1/1] scsi: fcoe: Fix transport not deattached when fcoe_if_init() fails
      https://git.kernel.org/mkp/scsi/c/4155658cee39
  

Patch

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 6ec296321ffc..38774a272e62 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -2491,6 +2491,7 @@  static int __init fcoe_init(void)
 
 out_free:
 	mutex_unlock(&fcoe_config_mutex);
+	fcoe_transport_detach(&fcoe_sw_transport);
 out_destroy:
 	destroy_workqueue(fcoe_wq);
 	return rc;