On Sat, 31 May 2008 18:46:15 -0700
Arjan van de Ven <arjan@infradead.org> wrote:
Cat sat on your keyboard?
What happens if this allocation fails? I think the driver is dead?
We've gone and freed the rd_ring and the td_ring and we _might_ have
allocated a new rd_ring and not a new td_ring.
And we've set vptr->rx_buf_sz, which may or may not be a problem.
And we've gone and left the interface in a downed state.
So hrm. It could all be a lot better. Just looking quickly at the
code I _think_ we might be able to do all the needed allocations
outside the lock and then swizzle them into place after taking the
lock. ie, something as simple as:
struct velocity_info *temp_vptr;
...
velocity_init_rd_ring(temp_vptr); /* Can use GFP_KERNEL! */
spin_lock_irqsave(&vptr->lock, flags);
velocity_free_td_ring(vptr);
velocity_free_rd_ring(vptr);
vptr->foo = temp_vptr->foo;
vptr->bar = temp_vptr->bar;
...
spin_unlock_irqrestore(&vptr->lock, flags);
?
--