Index: apps/app_voicemail.c
===================================================================
--- apps/app_voicemail.c	(revision 188040)
+++ apps/app_voicemail.c	(working copy)
@@ -8846,7 +8846,10 @@
 {
 	int res;
 	char *adsi_loaded = ast_module_helper("", "res_adsi.so", 0, 0, 0, 0);
+	char *smdi_loaded = ast_module_helper("", "res_smdi.so", 0, 0, 0, 0);
 	free(adsi_loaded);
+	free(smdi_loaded);
+
 	if (!adsi_loaded) {
 		/* If embedded, res_adsi may be known as "res_adsi" not "res_adsi.so" */
 		adsi_loaded = ast_module_helper("", "res_adsi", 0, 0, 0, 0);
@@ -8857,6 +8860,16 @@
 		}
 	}
 
+	if (!smdi_loaded) {
+		/* If embedded, res_smdi may be known as "res_smdi" not "res_smdi.so" */
+		smdi_loaded = ast_module_helper("", "res_smdi", 0, 0, 0, 0);
+		ast_free(smdi_loaded);
+		if (!smdi_loaded) {
+			ast_log(LOG_ERROR, "app_voicemail.so depends upon res_smdi.so\n");
+			return AST_MODULE_LOAD_DECLINE;
+		}
+	}
+
 	my_umask = umask(0);
 	umask(my_umask);
 	res = ast_register_application(app, vm_exec, synopsis_vm, descrip_vm);
Index: res/res_smdi.c
===================================================================
--- res/res_smdi.c	(revision 188040)
+++ res/res_smdi.c	(working copy)
@@ -1313,6 +1313,8 @@
 	.read = smdi_msg_read,
 };
 
+static int unload_module(void);
+
 static int load_module(void)
 {
 	int res;
@@ -1330,8 +1332,10 @@
 	/* load the config and start the listener threads*/
 	res = smdi_load(0);
 	if (res < 0) {
+		unload_module();
 		return res;
 	} else if (res == 1) {
+		unload_module();
 		ast_log(LOG_WARNING, "No SMDI interfaces are available to listen on, not starting SMDI listener.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
