diff mbox

[2/2] soc: qcom: smsm: Avoid the use of an uninitialized value

Message ID 20170315114357.14446-2-j.neuschaefer@gmx.net (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show

Commit Message

J. Neuschäfer March 15, 2017, 11:43 a.m. UTC
If qcom_smem_get returns an error besides -EPROBE_DEFER or -ENOENT,
don't assume that size has been set.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
 drivers/soc/qcom/smsm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/soc/qcom/smsm.c b/drivers/soc/qcom/smsm.c
index 3918645e5708..632c060c9cc0 100644
--- a/drivers/soc/qcom/smsm.c
+++ b/drivers/soc/qcom/smsm.c
@@ -441,7 +441,8 @@  static int smsm_get_size_info(struct qcom_smsm *smsm)
 	info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_SMSM_SIZE_INFO, &size);
 	if (PTR_ERR(info) == -EPROBE_DEFER) {
 		return PTR_ERR(info);
-	} else if (PTR_ERR(info) == -ENOENT || size != sizeof(*info)) {
+	} else if (PTR_ERR(info) == -ENOENT ||
+			(!IS_ERR(info) && size != sizeof(*info))) {
 		dev_warn(smsm->dev, "no smsm size info, using defaults\n");
 		smsm->num_entries = SMSM_DEFAULT_NUM_ENTRIES;
 		smsm->num_hosts = SMSM_DEFAULT_NUM_HOSTS;