freescale: beyond ARRAY_SIZE of fdev->chan
Subsystems (2)
PATCH 1/1 freescale: beyond ARRAY_SIZE of fdev->chan
Do not go beyond ARRAY_SIZE of fdev->chan
---
drivers/dma/fsldma.c +1 -1
@@ -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 ;
Quoted 3 lines · Roel Kluin
Do not go beyond
ARRAY_SIZEoffdev->chanSigned-off-by Roel Kluin <[email protected]>
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.
drivers/dma/fsldma.c static int __devinit fsl_dma_chan_probe(struct fsl_dm=
Quoted 6 lines
---
drivers/dma/fsldma.c +0
-0@@ -830,7 +830,7 @@ static int __devinit fsl_dma_chan_probe(struct fsl_dm=
a_device *fdev,
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0new_fsl_chan->reg.end - new_fsl_chan->reg.start + 1);
Quoted 2 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0new_fsl_chan->id =3D ((new_fsl_chan->reg.start=
- 0x100) & 0xfff) >> 7;
Quoted 1 line
- =C2=A0 =C2=A0 =C2=A0 if (
new_fsl_chan->id> FSL_DMA_MAX_CHANS_PER_DEVIC=
E) {
Quoted 1 line
+ =C2=A0 =C2=A0 =C2=A0 if (
new_fsl_chan->id>=3D FSL_DMA_MAX_CHANS_PER_DE=
VICE) {
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_err(fdev->dev,=
"There is no %d channel!\n",
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0new_fsl_chan->id);
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0err =3D
-EINVAL;