1 From 48de68a40aef032a2e198437f4781a83bfb938db Mon Sep 17 00:00:00 2001
2 From: Mike Christie <michaelc@cs.wisc.edu>
3 Date: Tue, 17 Nov 2009 21:25:16 -0600
4 Subject: SCSI: fc class: fix fc_transport_init error handling
6 From: Mike Christie <michaelc@cs.wisc.edu>
8 commit 48de68a40aef032a2e198437f4781a83bfb938db upstream.
10 If transport_class_register fails we should unregister any
11 registered classes, or we will leak memory or other
14 I did a quick modprobe of scsi_transport_fc to test the
17 Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
18 Signed-off-by: James Bottomley <James.Bottomley@suse.de>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
22 drivers/scsi/scsi_transport_fc.c | 17 ++++++++++++++---
23 1 file changed, 14 insertions(+), 3 deletions(-)
25 --- a/drivers/scsi/scsi_transport_fc.c
26 +++ b/drivers/scsi/scsi_transport_fc.c
27 @@ -648,11 +648,22 @@ static __init int fc_transport_init(void
29 error = transport_class_register(&fc_vport_class);
32 + goto unreg_host_class;
33 error = transport_class_register(&fc_rport_class);
36 - return transport_class_register(&fc_transport_class);
37 + goto unreg_vport_class;
38 + error = transport_class_register(&fc_transport_class);
40 + goto unreg_rport_class;
44 + transport_class_unregister(&fc_rport_class);
46 + transport_class_unregister(&fc_vport_class);
48 + transport_class_unregister(&fc_host_class);
52 static void __exit fc_transport_exit(void)