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@xxxxxxxxxx> Regards, Bjorn > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx> > --- > 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 >