Re: baycom_par dereference before check.

From: Jeff Garzik
Date: Fri Apr 16 2004 - 16:59:21 EST


Dave Jones wrote:
On Fri, Apr 16, 2004 at 10:25:41PM +0100, viro@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx wrote:

> > +++ linux-2.6.5/drivers/net/hamradio/baycom_par.c 2004-04-16 22:19:33.000000000 +0100
> > @@ -272,9 +272,13 @@
> > static void par96_interrupt(int irq, void *dev_id, struct pt_regs *regs)
> > {
> > struct net_device *dev = (struct net_device *)dev_id;
> > - struct baycom_state *bc = netdev_priv(dev);
> > + struct baycom_state *bc;
> > > > - if (!dev || !bc || bc->hdrv.magic != HDLCDRV_MAGIC)
> > + if (!dev)
> > + return;
> > +
> > + bc = netdev_priv(dev);
> > That's OK - netdev_priv(p) just adds a constant offset to p; no problem
> with doing that to NULL.

Good point. Still doesn't strike me as particularly nice though.


I would rather just remove the checks completely. The success of any of those checks is a BUG() condition that should never occur.

Jeff



-
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/