Skip to contentSkip to conversation

drivers/pnp/pnpbios/rsparser.c: fix an array overflow

PATCH New Adrian Bunk 1 participant 1 message Mar 27, 2005 Pnp support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/pnp/pnpbios/rsparser.c: fix an array overflow

This patch fixes an array overflow found by the Coverity checker.

drivers/pnp/pnpbios/rsparser.c renamed from drivers/pnp/pnpbios/rsparser.c.old +3 -1
@@ -72,7 +72,9 @@
 pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
 {
 	int i = 0;
-	while (!(res->dma_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_DMA) i++;
+	while (i < PNP_MAX_DMA && 
+			!(res->dma_resource[i].flags & IORESOURCE_UNSET))
+		i++;
 	if (i < PNP_MAX_DMA) {
 		res->dma_resource[i].flags = IORESOURCE_DMA;  // Also clears _UNSET flag
 		if (dma == -1) {