Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48de68a4 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley
Browse files

[SCSI] fc class: fix fc_transport_init error handling



If transport_class_register fails we should unregister any
registered classes, or we will leak memory or other
resources.

I did a quick modprobe of scsi_transport_fc to test the
patch.

Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent d685c262
Loading
Loading
Loading
Loading
+14 −3
Original line number Original line Diff line number Diff line
@@ -649,11 +649,22 @@ static __init int fc_transport_init(void)
		return error;
		return error;
	error = transport_class_register(&fc_vport_class);
	error = transport_class_register(&fc_vport_class);
	if (error)
	if (error)
		return error;
		goto unreg_host_class;
	error = transport_class_register(&fc_rport_class);
	error = transport_class_register(&fc_rport_class);
	if (error)
	if (error)
		goto unreg_vport_class;
	error = transport_class_register(&fc_transport_class);
	if (error)
		goto unreg_rport_class;
	return 0;

unreg_rport_class:
	transport_class_unregister(&fc_rport_class);
unreg_vport_class:
	transport_class_unregister(&fc_vport_class);
unreg_host_class:
	transport_class_unregister(&fc_host_class);
	return error;
	return error;
	return transport_class_register(&fc_transport_class);
}
}


static void __exit fc_transport_exit(void)
static void __exit fc_transport_exit(void)