Skip to contentSkip to conversation

freescale: beyond ARRAY_SIZE of fdev->chan

PATCH In review Roel Kluin 2 participants 2 messages May 19, 2009 – May 22, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

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
index da8a8ed..391b1bd 100644
@@ -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;
#1 lore raw
Quoted 3 lines · Roel Kluin

Do not go beyond ARRAY_SIZE of fdev->chan

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
index da8a8ed..391b1bd 100644
@@ -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;