drivers/net: Fix potential incorrect call for udelay()
Subsystems (4)
PATCH 1/1 drivers/net: Fix potential incorrect call for udelay()
From: Li Bin <[email protected]>
The variable delay_time as a module parameter can be set a value exceeding the limit of the udelay function. This patch checks the delay_time value to select mdelay() or udelay().
--- drivers/net/ethernet/8390/pcnet_cs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/8390/pcnet_cs.c +6 -2
@@ -1284,8 +1284,12 @@ static void dma_block_output(struct net_device *dev, int count, }outb_p (ENISR_RDC , nic_base +EN0_ISR );/* Ack intr. */ -if (info->flags &DELAY_OUTPUT ) -udelay ((long )delay_time); +if (info->flags &DELAY_OUTPUT ) { +if (delay_time >=1000 ) +mdelay ((long )delay_time/1000 ); +else +udelay (delay_time); + } ei_status.dmaing &= ~0x01 ; }
Signature · 1 line
1.8.2.2
Quoted 7 lines · On Mon, 23 Dec 2013 17:33:44 +0800 Libin <[email protected]> wrote:
From: Li Bin <[email protected]>
The variable
delay_timeas a module parameter can be set a value exceeding the limit of the udelay function. This patch checks thedelay_timevalue to selectmdelay()orudelay().Signed-off-by Li Bin <[email protected]>
Nobody should need to set a delay time that long, so this seems a rather surplus check.
Alan
Quoted 17 lines · Libin
From: Li Bin <[email protected]>
The variable
delay_timeas a module parameter can be set a value exceeding the limit of the udelay function. This patch checks thedelay_timevalue to selectmdelay()orudelay().Signed-off-by Li Bin <[email protected]>--- drivers/net/ethernet/8390/pcnet_cs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/net/ethernet/8390/pcnet_cs.c +0
-0
drivers/net/ethernet/8390/pcnet_cs.c static void dma_block_output(struct net_device *dev, int count, · line 1289
Quoted 8 lines
drivers/net/ethernet/8390/pcnet_cs.c +3
-2@@ -1284,8 +1284,12 @@ static void dma_block_output(struct net_device *dev, int count, }outb_p (ENISR_RDC , nic_base +EN0_ISR );/* Ack intr. */ -if (info->flags &DELAY_OUTPUT ) -udelay ((long )delay_time); +if (info->flags &DELAY_OUTPUT ) { +if (delay_time >=1000 ) +mdelay ((long )delay_time/1000 );
Indeed use of mdelay is discouraged.
I prefer to limit delay_time less than 1000.
Tingwei
Quoted 15 lines
drivers/net/ethernet/8390/pcnet_cs.c +3
-1+else +udelay (delay_time); + } ei_status.dmaing &= ~0x01 ; } --1.8.2.2
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html