aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>2020-05-25 19:28:50 +0300
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>2020-05-25 19:41:48 +0300
commitb51bb0a58b06dc2ae56581c981f2c639e78af284 (patch)
tree716d22d4958a40107ea6bea9252eb68a2711e727
parente6d2018e816b446425f60455936b90d62eb13269 (diff)
soc: qcom: socinfo: fix printing of pmic_model
Print sensible string instead of just "(null)" for unknown PMIC models. Also as we are at it, do not let debugfs handler access past pmic_models array. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
-rw-r--r--drivers/soc/qcom/socinfo.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index 0e6adf1161c0..41f48c3447cc 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -269,7 +269,10 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p)
if (model < 0)
return -EINVAL;
- seq_printf(seq, "%s\n", pmic_models[model]);
+ if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model])
+ seq_printf(seq, "%s\n", pmic_models[model]);
+ else
+ seq_printf(seq, "unknown (%d)\n", model);
return 0;
}