[PATCH] De-register pbap drivers on init failure scenarios

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unwind the driver registration/phonebook initialization stack on pbap plugin init failure scenarios.


---
 plugins/pbap.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/plugins/pbap.c b/plugins/pbap.c
index af4b452..2d3bebd 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -892,21 +892,36 @@ static int pbap_init(void)
 
 	err = phonebook_init();
 	if (err < 0)
-		return err;
+		goto fail_pb_init;
 
 	err = obex_mime_type_driver_register(&mime_pull);
 	if (err < 0)
-		return err;
+		goto fail_mime_pull;
 
 	err = obex_mime_type_driver_register(&mime_list);
 	if (err < 0)
-		return err;
+		goto fail_mime_list;
 
 	err = obex_mime_type_driver_register(&mime_vcard);
 	if (err < 0)
-		return err;
+		goto fail_mime_vcard;
+
+	err = obex_service_driver_register(&pbap);
+	if (err < 0)
+			goto fail_pbap_reg;
 
-	return obex_service_driver_register(&pbap);
+	return 0;
+
+fail_pbap_reg:
+	obex_mime_type_driver_unregister(&mime_vcard);
+fail_mime_vcard:
+	obex_mime_type_driver_unregister(&mime_list);
+fail_mime_list:
+	obex_mime_type_driver_unregister(&mime_pull);
+fail_mime_pull:
+	phonebook_exit();
+fail_pb_init:
+	return err;
 }
 
 static void pbap_exit(void)
-- 
1.7.1.1



--------------------------------------------------------------
Intel Shannon Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
Business address: Dromore House, East Park, Shannon, Co. Clare

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.


--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux