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

From: Jonathan NeuschÃfer
Date: Wed Mar 15 2017 - 07:46:52 EST


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@xxxxxxx>
---
drivers/soc/qcom/smsm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

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;
--
2.11.0