Message ID | 20200525164817.2938638-2-dmitry.baryshkov@linaro.org |
---|---|
State | Accepted |
Commit | e9247e2ce5778678c8d631e26ef79dbccedbe6d0 |
Headers | show |
Series | [1/4] soc: qcom: socinfo: add support for newer socinfo data | expand |
On Mon 25 May 09:48 PDT 2020, Dmitry Baryshkov wrote: > 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. > Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Regards, Bjorn > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- > drivers/soc/qcom/socinfo.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > 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; > } > -- > 2.26.2 >
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; }
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> --- drivers/soc/qcom/socinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.26.2