]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.3/scsi-fc-class-fix-fc_transport_init-error-handling.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.3 / scsi-fc-class-fix-fc_transport_init-error-handling.patch
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
5
6 From: Mike Christie <michaelc@cs.wisc.edu>
7
8 commit 48de68a40aef032a2e198437f4781a83bfb938db upstream.
9
10 If transport_class_register fails we should unregister any
11 registered classes, or we will leak memory or other
12 resources.
13
14 I did a quick modprobe of scsi_transport_fc to test the
15 patch.
16
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>
20
21 ---
22 drivers/scsi/scsi_transport_fc.c | 17 ++++++++++++++---
23 1 file changed, 14 insertions(+), 3 deletions(-)
24
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
28 return error;
29 error = transport_class_register(&fc_vport_class);
30 if (error)
31 - return error;
32 + goto unreg_host_class;
33 error = transport_class_register(&fc_rport_class);
34 if (error)
35 - return error;
36 - return transport_class_register(&fc_transport_class);
37 + goto unreg_vport_class;
38 + error = transport_class_register(&fc_transport_class);
39 + if (error)
40 + goto unreg_rport_class;
41 + return 0;
42 +
43 +unreg_rport_class:
44 + transport_class_unregister(&fc_rport_class);
45 +unreg_vport_class:
46 + transport_class_unregister(&fc_vport_class);
47 +unreg_host_class:
48 + transport_class_unregister(&fc_host_class);
49 + return error;
50 }
51
52 static void __exit fc_transport_exit(void)