sysmon: check if mutex lock is available

Modem boots up completedly and opens the logical channel.  Mutex is initialized
at that time.  If sysmon_get_reason is accessed before that, panic occurs by
accessing the uninitialized mutex.  Since this is a valid access scenario, we
add a flag to check if the subsystem has been probed, and return an error if
sysmon_get_reason() gets called before that.

Change-Id: If81f9fc1be5b9e0e9e6e69366d1b8d6df35e2857
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/arch/arm/mach-msm/sysmon.c b/arch/arm/mach-msm/sysmon.c
index 46f6518..1677713 100644
--- a/arch/arm/mach-msm/sysmon.c
+++ b/arch/arm/mach-msm/sysmon.c
@@ -38,6 +38,7 @@
 
 struct sysmon_subsys {
 	struct mutex		lock;
+	bool			probed;
 	struct smd_channel	*chan;
 	bool			chan_open;
 	struct completion	resp_ready;
@@ -221,6 +222,9 @@
 	if ((!ss->chan_open) && (dest_ss != SYSMON_SS_EXT_MODEM))
 		return -ENODEV;
 
+	if (!ss->probed)
+		return -ENODEV;
+
 	mutex_lock(&ss->lock);
 	ret = sysmon_send_msg(ss, tx_buf, ARRAY_SIZE(tx_buf));
 	if (ret)
@@ -268,6 +272,7 @@
 
 	ss = &subsys[pdev->id];
 	mutex_init(&ss->lock);
+	ss->probed = true;
 
 	switch (ss->transport) {
 	case TRANSPORT_SMD: