[lvc-project] [PATCH 5/10] Input: adp5588-keys - added a check key_val
Fedor Pchelkin
pchelkin at ispras.ru
Thu Sep 19 17:36:57 MSK 2024
On Thu, 19. Sep 17:34, Fedor Pchelkin wrote:
> On Thu, 19. Sep 17:29, Denis Arefev wrote:
> > No upstream commit exists for this commit.
>
> Действительно. Ведь в upstream эта проблема по-прежнему есть. Прежде чем
> править что-либо в stable, нужно исправление в upstream.
>
> Для предварительного обсуждения патчей при необходимости этого существует
> список рассылки lvc-patches at linuxtesting.org .
>
> >
> > If the adp5588_read function returns 0, then there will be an
> > overflow of the kpad->keycode[key_val - 1] buffer.
> >
> > If the adp5588_read function returns a negative value, then the
> > logic is broken - the wrong value is used as an index of
> > the kpad->keycode array.
> >
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> >
> > Fixes: 69a4af606ed4 ("Input: adp5588-keys - support GPI events for ADP5588 devices")
> > Cc: stable at vger.kernel.org
> > Signed-off-by: Denis Arefev <arefev at swemel.ru>
> > ---
> > drivers/input/keyboard/adp5588-keys.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
> > index 90a59b973d00..19be8054eb5f 100644
> > --- a/drivers/input/keyboard/adp5588-keys.c
> > +++ b/drivers/input/keyboard/adp5588-keys.c
> > @@ -272,6 +272,8 @@ static void adp5588_report_events(struct adp5588_kpad *kpad, int ev_cnt)
> > int key = adp5588_read(kpad->client, Key_EVENTA + i);
> > int key_val = key & KEY_EV_MASK;
> >
> > + if (key_val <= 0)
> > + continue;
Лучше проверять key.
key_val получается при наложении маски и лежит в диапазоне [0, 127].
Отрицательных значений иметь не может.
> > if (key_val >= GPI_PIN_BASE && key_val <= GPI_PIN_END) {
> > for (j = 0; j < kpad->gpimapsize; j++) {
> > if (key_val == kpad->gpimap[j].pin) {
> > --
> > 2.25.1
More information about the lvc-project
mailing list