3.1-git ipoib: fix NULL pointer dereference
Subsystems (3)
cover 3.1-git ipoib: fix NULL pointer dereference
The following series
- fixes a NULL pointer dereferences in ipoib_start_xmit()
- renames variable 'n' to 'dst_neigh' to make the code better readable
Question: I am unsure about the usage of likely() here, as I run into the else branch, maybe it is not that unlikely and likely() should be removed?
---
Bernd Schubert (2):
Fix possible Null pointer dereference in ipoib_start_xmit() Rename 'n' into a longer variable name.
drivers/infiniband/ulp/ipoib/ipoib_main.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
--
Bernd Schubert
Fraunhofer ITWM / FhGFS
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/2 Fix possible Null pointer dereference in ipoib_start_xmit()
This will fix https://bugzilla.kernel.org/show_bug.cgi?id=41212
fslab2 login: [ 114.392408] EXT4-fs (sdc): barriers disabled
[ 114.449737] EXT4-fs (sdc): mounted filesystem with writeback data mode. Opts: journal_async_commit,barrier=0,data=writeback [ 240.944030] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 [ 240.948007] IP: [<ffffffffa0366ce9>] ipoib_start_xmit+0x39/0x280 [ib_ipoib] [...] [ 240.948007] Call Trace: [ 240.948007] <IRQ> [ 240.948007] [<ffffffff812cd5e0>] dev_hard_start_xmit+0x2a0/0x590 [ 240.948007] [<ffffffff8131f680>] ? arp_create+0x70/0x200 [ 240.948007] [<ffffffff812e8e1f>] sch_direct_xmit+0xef/0x1c0
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_main.c +5 -3
@@ -717,11 +717,13 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) {struct ipoib_dev_priv *priv =netdev_priv (dev);struct ipoib_neigh *neigh; -struct neighbour *n; +struct neighbour *n =NULL ;unsigned long flags; - n =dst_get_neighbour (skb_dst (skb)); -if (likely (skb_dst (skb) && n)) { +if (likely (skb_dst (skb))) + n =dst_get_neighbour (skb_dst (skb)); + +if (likely (n)) {if (unlikely (!*to_ipoib_neigh (n))) {ipoib_path_lookup (skb, dev);return NETDEV_TX_OK ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 Rename 'n' into a longer variable name.
In reply to Bernd SchubertWhen it comes to me variable names consisting of a single letter should be forbidden by coding style guide lines, as it is rather difficult to search for single letter, such as 'n'.
Rename struct neighbour *n to dst_neigh
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_main.c +8 -7
@@ -717,22 +717,22 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) {struct ipoib_dev_priv *priv =netdev_priv (dev);struct ipoib_neigh *neigh; -struct neighbour *n =NULL ; +struct neighbour *dst_neigh =NULL ;unsigned long flags;if (likely (skb_dst (skb))) - n =dst_get_neighbour (skb_dst (skb)); + dst_neigh =dst_get_neighbour (skb_dst (skb)); -if (likely (n)) { -if (unlikely (!*to_ipoib_neigh (n))) { +if (likely (dst_neigh)) { +if (unlikely (!*to_ipoib_neigh (dst_neigh))) {ipoib_path_lookup (skb, dev);return NETDEV_TX_OK ; } - neigh = *to_ipoib_neigh (n); + neigh = *to_ipoib_neigh (dst_neigh);if (unlikely ((memcmp (&neigh->dgid.raw, - n->ha +4 , + dst_neigh->ha +4 ,sizeof (union ib_gid ))) || (neigh->dev != dev))) {spin_lock_irqsave (&priv->lock, flags);
@@ -758,7 +758,8 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)return NETDEV_TX_OK ; } }else if (neigh->ah) { -ipoib_send (dev, skb, neigh->ah,IPOIB_QPN (n->ha)); +ipoib_send (dev, skb, neigh->ah, +IPOIB_QPN (dst_neigh->ha));return NETDEV_TX_OK ; }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] Fix possible Null pointer dereference in ipoib_start_xmit()
In reply to Bernd SchubertThanks, applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] Rename 'n' into a longer variable name.
In reply to Bernd SchubertFrom: Bernd Schubert <[email protected]>
Date: Tue, 16 Aug 2011 12:56:59 +0200
Quoted 3 lines
When it comes to me variable names consisting of a single letter should be forbidden by coding style guide lines, as it is rather difficult to search for single letter, such as 'n'.
I totally disagree and use such things aggressively myself.
I am not applying this patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html