aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2007-02-07 03:12:13 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2007-02-08 15:39:08 -0500
commit719647e2131585ea0a82b05d3745b36be32975d8 (patch)
tree0f1670ed16de236e71d8e12803e7bdca5e3c569b
parentbb5aa42734e72b3f02fc0b3cdd6105083f9880f1 (diff)
[IRLAN]: handle out of memory errors
This patch checks return values: - irlmp_register_client() - irlmp_register_service() - irlan_open() Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Samuel Ortiz <samuel@sortiz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/irda/irlan/irlan_common.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
index 2bb04ac09329..310776dd6109 100644
--- a/net/irda/irlan/irlan_common.c
+++ b/net/irda/irlan/irlan_common.c
@@ -144,12 +144,18 @@ static int __init irlan_init(void)
144 /* Register with IrLMP as a client */ 144 /* Register with IrLMP as a client */
145 ckey = irlmp_register_client(hints, &irlan_client_discovery_indication, 145 ckey = irlmp_register_client(hints, &irlan_client_discovery_indication,
146 NULL, NULL); 146 NULL, NULL);
147 147 if (!ckey)
148 goto err_ckey;
149
148 /* Register with IrLMP as a service */ 150 /* Register with IrLMP as a service */
149 skey = irlmp_register_service(hints); 151 skey = irlmp_register_service(hints);
152 if (!skey)
153 goto err_skey;
150 154
151 /* Start the master IrLAN instance (the only one for now) */ 155 /* Start the master IrLAN instance (the only one for now) */
152 new = irlan_open(DEV_ADDR_ANY, DEV_ADDR_ANY); 156 new = irlan_open(DEV_ADDR_ANY, DEV_ADDR_ANY);
157 if (!new)
158 goto err_open;
153 159
154 /* The master will only open its (listen) control TSAP */ 160 /* The master will only open its (listen) control TSAP */
155 irlan_provider_open_ctrl_tsap(new); 161 irlan_provider_open_ctrl_tsap(new);
@@ -158,6 +164,17 @@ static int __init irlan_init(void)
158 irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS); 164 irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
159 165
160 return 0; 166 return 0;
167
168err_open:
169 irlmp_unregister_service(skey);
170err_skey:
171 irlmp_unregister_client(ckey);
172err_ckey:
173#ifdef CONFIG_PROC_FS
174 remove_proc_entry("irlan", proc_irda);
175#endif /* CONFIG_PROC_FS */
176
177 return -ENOMEM;
161} 178}
162 179
163static void __exit irlan_cleanup(void) 180static void __exit irlan_cleanup(void)