a minor bug in via-rhine driver for linux

From: pin xue
Date: Tue Apr 04 2006 - 10:40:11 EST


Hi:

kernel source version : 2.6.14

file : drivers/net/via-rhine.c

function : alloc_tbufs(), line 1021~1039

problem line : 1035
rp->tx_buf[i] = &rp->tx_bufs[i * PKT_BUF_SZ];

fix: line 1035 should be
if ( rp->quirks & rqRhineI )
rp->tx_buf[i] = &rp->tx_bufs[i * PKT_BUF_SZ];

explaination:
line 718 : here we set rqRhineI flag only for old chips
line 922 : here we allocate buffers and alloc rp->tx_bufs only when
rqRhineI flag setted.
line 1035: here we initialize buffers, but set rp->tx_buf[] based on
tx_bufs anyway.
line 1273: here we use the buffers and refer rp->tx_buf[] only when
rqRhineI flag setted.
Currently, line 1035 does not cause any invalid memory accessing but
calculating and saving some invalid memory address.

comments:
I'm reading this driver and line 1035 confused me for a moment.



--
Best Regards!

Yang Wu

Mobile Phone: +86-013636674084
WorldWideWeb: http://www.pinxue.net

--
Best Regards!

Yang Wu

Mobile Phone: +86-013636674084
WorldWideWeb: http://www.pinxue.net
-
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/