* re: [SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference (v2)
@ 2011-09-26 13:40 Dan Carpenter
2011-09-26 14:20 ` Neil Horman
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2011-09-26 13:40 UTC (permalink / raw)
To: nhorman; +Cc: netdev, linux-scsi
Hi Neil,
c98bc57ee65b6 "[SCSI] cxgb3i: convert cdev->l2opt to use rcu to
prevent NULL dereference (v2)" from linux-next introduces a usinging
uninitialized variable bug.
struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
struct net_device *dev)
{
- struct l2t_entry *e;
- struct l2t_data *d = L2DATA(cdev);
+ struct l2t_entry *e = NULL;
+ struct l2t_data *d;
u32 addr = *(u32 *) neigh->primary_key;
int ifidx = neigh->dev->ifindex;
int hash = arp_hash(addr, ifidx, d);
^
Uninitialized variable.
struct port_info *p = netdev_priv(dev);
int smt_idx = p->port_id;
+ rcu_read_lock();
+ d = L2DATA(cdev);
+ if (!d)
+ goto done_rcu;
+
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference (v2)
2011-09-26 13:40 [SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference (v2) Dan Carpenter
@ 2011-09-26 14:20 ` Neil Horman
2011-09-26 14:31 ` James Bottomley
0 siblings, 1 reply; 4+ messages in thread
From: Neil Horman @ 2011-09-26 14:20 UTC (permalink / raw)
To: Dan Carpenter; +Cc: netdev, linux-scsi
On Mon, Sep 26, 2011 at 04:40:48PM +0300, Dan Carpenter wrote:
> Hi Neil,
>
> c98bc57ee65b6 "[SCSI] cxgb3i: convert cdev->l2opt to use rcu to
> prevent NULL dereference (v2)" from linux-next introduces a usinging
> uninitialized variable bug.
>
> struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
> struct net_device *dev)
> {
> - struct l2t_entry *e;
> - struct l2t_data *d = L2DATA(cdev);
> + struct l2t_entry *e = NULL;
> + struct l2t_data *d;
> u32 addr = *(u32 *) neigh->primary_key;
> int ifidx = neigh->dev->ifindex;
> int hash = arp_hash(addr, ifidx, d);
> ^
> Uninitialized variable.
>
> struct port_info *p = netdev_priv(dev);
> int smt_idx = p->port_id;
>
> + rcu_read_lock();
> + d = L2DATA(cdev);
> + if (!d)
> + goto done_rcu;
> +
>
> regards,
> dan carpenter
>
Yup, thanks, you need this to9 fix the uninitalized var.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
l2t.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
index 3808f99..4154097 100644
--- a/drivers/net/cxgb3/l2t.c
+++ b/drivers/net/cxgb3/l2t.c
@@ -302,9 +302,9 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
{
struct l2t_entry *e = NULL;
struct l2t_data *d;
+ int hash;
u32 addr = *(u32 *) neigh->primary_key;
int ifidx = neigh->dev->ifindex;
- int hash = arp_hash(addr, ifidx, d);
struct port_info *p = netdev_priv(dev);
int smt_idx = p->port_id;
@@ -313,6 +313,8 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
if (!d)
goto done_rcu;
+ hash = arp_hash(addr, ifidx, d);
+
write_lock_bh(&d->lock);
for (e = d->l2tab[hash].first; e; e = e->next)
if (e->addr == addr && e->ifindex == ifidx &&
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference (v2)
2011-09-26 14:20 ` Neil Horman
@ 2011-09-26 14:31 ` James Bottomley
2011-09-26 15:02 ` Neil Horman
0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2011-09-26 14:31 UTC (permalink / raw)
To: Neil Horman; +Cc: Dan Carpenter, netdev, linux-scsi
On Mon, 2011-09-26 at 10:20 -0400, Neil Horman wrote:
> On Mon, Sep 26, 2011 at 04:40:48PM +0300, Dan Carpenter wrote:
> > Hi Neil,
> >
> > c98bc57ee65b6 "[SCSI] cxgb3i: convert cdev->l2opt to use rcu to
> > prevent NULL dereference (v2)" from linux-next introduces a usinging
> > uninitialized variable bug.
> >
> > struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
> > struct net_device *dev)
> > {
> > - struct l2t_entry *e;
> > - struct l2t_data *d = L2DATA(cdev);
> > + struct l2t_entry *e = NULL;
> > + struct l2t_data *d;
> > u32 addr = *(u32 *) neigh->primary_key;
> > int ifidx = neigh->dev->ifindex;
> > int hash = arp_hash(addr, ifidx, d);
> > ^
> > Uninitialized variable.
> >
> > struct port_info *p = netdev_priv(dev);
> > int smt_idx = p->port_id;
> >
> > + rcu_read_lock();
> > + d = L2DATA(cdev);
> > + if (!d)
> > + goto done_rcu;
> > +
> >
> > regards,
> > dan carpenter
> >
>
> Yup, thanks, you need this to9 fix the uninitalized var.
I rolled this into the original.
James
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference (v2)
2011-09-26 14:31 ` James Bottomley
@ 2011-09-26 15:02 ` Neil Horman
0 siblings, 0 replies; 4+ messages in thread
From: Neil Horman @ 2011-09-26 15:02 UTC (permalink / raw)
To: James Bottomley; +Cc: Dan Carpenter, netdev, linux-scsi
On Mon, Sep 26, 2011 at 09:31:15AM -0500, James Bottomley wrote:
> On Mon, 2011-09-26 at 10:20 -0400, Neil Horman wrote:
> > On Mon, Sep 26, 2011 at 04:40:48PM +0300, Dan Carpenter wrote:
> > > Hi Neil,
> > >
> > > c98bc57ee65b6 "[SCSI] cxgb3i: convert cdev->l2opt to use rcu to
> > > prevent NULL dereference (v2)" from linux-next introduces a usinging
> > > uninitialized variable bug.
> > >
> > > struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
> > > struct net_device *dev)
> > > {
> > > - struct l2t_entry *e;
> > > - struct l2t_data *d = L2DATA(cdev);
> > > + struct l2t_entry *e = NULL;
> > > + struct l2t_data *d;
> > > u32 addr = *(u32 *) neigh->primary_key;
> > > int ifidx = neigh->dev->ifindex;
> > > int hash = arp_hash(addr, ifidx, d);
> > > ^
> > > Uninitialized variable.
> > >
> > > struct port_info *p = netdev_priv(dev);
> > > int smt_idx = p->port_id;
> > >
> > > + rcu_read_lock();
> > > + d = L2DATA(cdev);
> > > + if (!d)
> > > + goto done_rcu;
> > > +
> > >
> > > regards,
> > > dan carpenter
> > >
> >
> > Yup, thanks, you need this to9 fix the uninitalized var.
>
> I rolled this into the original.
>
Thank you!
Neil
> James
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-09-26 15:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-26 13:40 [SCSI] cxgb3i: convert cdev->l2opt to use rcu to prevent NULL dereference (v2) Dan Carpenter
2011-09-26 14:20 ` Neil Horman
2011-09-26 14:31 ` James Bottomley
2011-09-26 15:02 ` Neil Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox