Re: [PATCH] freescale: beyond ARRAY_SIZE of fdev->chan

From: Li Yang
Date: Fri May 22 2009 - 04:03:51 EST


On Wed, May 20, 2009 at 7:17 AM, Roel Kluin <roel.kluin@xxxxxxxxx> wrote:
> Do not go beyond ARRAY_SIZE of fdev->chan
>
> Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>

Indeed, thanks.

But I would like the title and description of this patch be changed to
like this:

fsldma: fix check on potential fdev->chan[] overflow

Fix the check of potential array overflow when using corrupted channel
device tree nodes.

> ---
> diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
> index da8a8ed..391b1bd 100644
> --- a/drivers/dma/fsldma.c
> +++ b/drivers/dma/fsldma.c
> @@ -830,7 +830,7 @@ static int __devinit fsl_dma_chan_probe(struct fsl_dma_device *fdev,
> Â Â Â Â Â Â Â Â Â Â Â Ânew_fsl_chan->reg.end - new_fsl_chan->reg.start + 1);
>
> Â Â Â Ânew_fsl_chan->id = ((new_fsl_chan->reg.start - 0x100) & 0xfff) >> 7;
> - Â Â Â if (new_fsl_chan->id > FSL_DMA_MAX_CHANS_PER_DEVICE) {
> + Â Â Â if (new_fsl_chan->id >= FSL_DMA_MAX_CHANS_PER_DEVICE) {
> Â Â Â Â Â Â Â Âdev_err(fdev->dev, "There is no %d channel!\n",
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Ânew_fsl_chan->id);
> Â Â Â Â Â Â Â Âerr = -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/