From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: David Airlie <airlied@linux.ie>,
kernel-janitors@vger.kernel.org, Jyri Sarha <jsarha@ti.com>,
dri-devel@lists.freedesktop.org,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 1/2] drm/bridge: sii902x: re-order conditions to prevent out of bounds read
Date: Fri, 07 Jun 2019 07:58:23 +0000 [thread overview]
Message-ID: <20190607075823.GO31203@kadam> (raw)
In-Reply-To: <5CFA14CD.5010502@bfs.de>
On Fri, Jun 07, 2019 at 09:39:57AM +0200, walter harms wrote:
>
>
> Am 07.06.2019 09:27, schrieb Dan Carpenter:
> > This should check that "i" is within bounds before checking reading from
> > the array.
> >
> > Fixes: ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/gpu/drm/bridge/sii902x.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
> > index d6f98d388ac2..6b03616d6bc3 100644
> > --- a/drivers/gpu/drm/bridge/sii902x.c
> > +++ b/drivers/gpu/drm/bridge/sii902x.c
> > @@ -589,8 +589,8 @@ static int sii902x_audio_hw_params(struct device *dev, void *data,
> > if (ret)
> > goto out;
> >
> > - for (i = 0; sii902x->audio.i2s_fifo_sequence[i] &&
> > - i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence); i++)
> > + for (i = 0; i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence) &&
> > + sii902x->audio.i2s_fifo_sequence[i]; i++)
> > regmap_write(sii902x->regmap,
> > SII902X_TPI_I2S_ENABLE_MAPPING_REG,
> > sii902x->audio.i2s_fifo_sequence[i]);
>
>
> mmmh, i am a big fan of KISS and in this case i would check sii902x->audio.i2s_fifo_sequence[i]
> outside for(). like:
>
> for (i = 0; i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence); i++) {
> if (!sii902x->audio.i2s_fifo_sequence[i])
> break;
That's probably a better way, but either way is acceptable and I left it
how the author wrote it.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: David Airlie <airlied@linux.ie>,
kernel-janitors@vger.kernel.org, Jyri Sarha <jsarha@ti.com>,
dri-devel@lists.freedesktop.org,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 1/2] drm/bridge: sii902x: re-order conditions to prevent out of bounds read
Date: Fri, 7 Jun 2019 10:58:23 +0300 [thread overview]
Message-ID: <20190607075823.GO31203@kadam> (raw)
In-Reply-To: <5CFA14CD.5010502@bfs.de>
On Fri, Jun 07, 2019 at 09:39:57AM +0200, walter harms wrote:
>
>
> Am 07.06.2019 09:27, schrieb Dan Carpenter:
> > This should check that "i" is within bounds before checking reading from
> > the array.
> >
> > Fixes: ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/gpu/drm/bridge/sii902x.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
> > index d6f98d388ac2..6b03616d6bc3 100644
> > --- a/drivers/gpu/drm/bridge/sii902x.c
> > +++ b/drivers/gpu/drm/bridge/sii902x.c
> > @@ -589,8 +589,8 @@ static int sii902x_audio_hw_params(struct device *dev, void *data,
> > if (ret)
> > goto out;
> >
> > - for (i = 0; sii902x->audio.i2s_fifo_sequence[i] &&
> > - i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence); i++)
> > + for (i = 0; i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence) &&
> > + sii902x->audio.i2s_fifo_sequence[i]; i++)
> > regmap_write(sii902x->regmap,
> > SII902X_TPI_I2S_ENABLE_MAPPING_REG,
> > sii902x->audio.i2s_fifo_sequence[i]);
>
>
> mmmh, i am a big fan of KISS and in this case i would check sii902x->audio.i2s_fifo_sequence[i]
> outside for(). like:
>
> for (i = 0; i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence); i++) {
> if (!sii902x->audio.i2s_fifo_sequence[i])
> break;
That's probably a better way, but either way is acceptable and I left it
how the author wrote it.
regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-06-07 7:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20190607072733epcas1p34d1a3afb68cb189947c794b1fc8c73a0@epcas1p3.samsung.com>
2019-06-07 7:27 ` [PATCH 1/2] drm/bridge: sii902x: re-order conditions to prevent out of bounds read Dan Carpenter
2019-06-07 7:27 ` Dan Carpenter
2019-06-07 7:39 ` walter harms
2019-06-07 7:39 ` walter harms
2019-06-07 7:58 ` Dan Carpenter [this message]
2019-06-07 7:58 ` Dan Carpenter
2019-06-07 9:43 ` Andrzej Hajda
2019-06-07 9:43 ` Andrzej Hajda
2019-06-07 13:15 ` Andrzej Hajda
2019-06-07 13:15 ` Andrzej Hajda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190607075823.GO31203@kadam \
--to=dan.carpenter@oracle.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=jsarha@ti.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=wharms@bfs.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.