platform: msm_shared: Do not return pointer allocated on stack

RPM response is read into local buffer which is allocated
on stack and returned to the caller. Returning pointer on stack
will have undefined behaviour, pass response buffer from the caller
to avoid this problem.

Change-Id: Iac967725659166fb6100a02fbac68041ce8cb7af
diff --git a/platform/msm_shared/smd.c b/platform/msm_shared/smd.c
index 66b4b9f..3616e2b 100644
--- a/platform/msm_shared/smd.c
+++ b/platform/msm_shared/smd.c
@@ -209,12 +209,10 @@
 	ch_ptr->port_info->ch1.read_index = read_index;
 }
 
-uint8_t* smd_read(smd_channel_info_t *ch, uint32_t *len, int ch_type)
+void smd_read(smd_channel_info_t *ch, uint32_t *len, int ch_type, uint32_t *response)
 {
 	smd_pkt_hdr smd_hdr;
 	uint32_t size = 0;
-	/* Response as per the current design does not exceed 20 bytes */
-	uint32_t response[5];
 
 	/* Read the indices from smem */
 	ch->port_info = smem_get_alloc_entry(SMEM_SMD_BASE_ID + ch->alloc_entry.cid,
@@ -222,7 +220,7 @@
 	if(!ch->port_info->ch1.DTR_DSR)
 	{
 		dprintf(CRITICAL,"%s: DTR is off\n", __func__);
-		return -1;
+		return;
 	}
 
 	/* Wait until the data updated in the smd buffer is equal to smd packet header*/
@@ -247,9 +245,9 @@
 	}
 
 	/* We are good to return the response now */
-	memcpy_from_fifo(ch, response, sizeof(response));
+	memcpy_from_fifo(ch, response, smd_hdr.pkt_size);
 
-	arch_invalidate_cache_range((addr_t)response, sizeof(response));
+	arch_invalidate_cache_range((addr_t)response, smd_hdr.pkt_size);
 
 	return response;
 }