Skip to contentSkip to conversation

macvtap: slient sparse warnings

PATCH Superseded Jason Wang 2 participants 4 messages Jun 13, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/2 macvtap: slient sparse warnings

This patch silents the following sparse warnings:

drivers/net/macvtap.c:98:9: warning: incorrect type in assignment (different address spaces)
drivers/net/macvtap.c:98:9: expected struct macvtap_queue *<noident>
drivers/net/macvtap.c:98:9: got struct macvtap_queue [noderef]
<asn:4>*<noident>
drivers/net/macvtap.c:120:9: warning: incorrect type in assignment (different address spaces)
drivers/net/macvtap.c:120:9: expected struct macvtap_queue *<noident>
drivers/net/macvtap.c:120:9: got struct macvtap_queue [noderef]
<asn:4>*<noident>
drivers/net/macvtap.c:151:22: error: incompatible types in comparison expression (different address spaces)
drivers/net/macvtap.c:233:23: error: incompatible types in comparison expression (different address spaces)
drivers/net/macvtap.c:243:23: error: incompatible types in comparison expression (different address spaces)
drivers/net/macvtap.c:247:15: error: incompatible types in comparison expression (different address spaces)
CC [M] drivers/net/macvtap.o
drivers/net/macvlan.c:232:24: error: incompatible types in comparison expression (different address spaces)

---
 drivers/net/macvtap.c      |    2 +-
 include/linux/if_macvlan.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/macvtap.c +1 -1
index 992151c..acf55ba 100644
@@ -429,7 +429,7 @@ static int macvtap_open(struct inode *inode, struct file *file)
 	if (!q)
 		goto out;
 
-	q->sock.wq = &q->wq;
+	rcu_assign_pointer(q->sock.wq, &q->wq);
 	init_waitqueue_head(&q->wq.wait);
 	q->sock.type = SOCK_RAW;
 	q->sock.state = SS_CONNECTED;
include/linux/if_macvlan.h +1 -1
index 1912133..f49a9f6 100644
@@ -70,7 +70,7 @@ struct macvlan_dev {
 	int (*receive)(struct sk_buff *skb);
 	int (*forward)(struct net_device *dev, struct sk_buff *skb);
 	/* This array tracks active taps. */
-	struct macvtap_queue	*taps[MAX_MACVTAP_QUEUES];
+	struct macvtap_queue	__rcu *taps[MAX_MACVTAP_QUEUES];
 	/* This list tracks all taps (both enabled and disabled) */
 	struct list_head	queue_list;
 	int			numvtaps;
Signature · 1 line
1.7.1
author
#1 lore raw

PATCH 2/2 macvtap: fix uninitialized return value macvtap_ioctl_set_queue()

Return -EINVAL on illegal flag instead of uninitialized value. This fixes the kbuild test warning.

---
 drivers/net/macvtap.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/macvtap.c +2 -0
index acf55ba..9f03ce3 100644
@@ -969,6 +969,8 @@ static int macvtap_ioctl_set_queue(struct file *file, unsigned int flags)
 		ret = macvtap_enable_queue(vlan->dev, file, q);
 	else if (flags & IFF_DETACH_QUEUE)
 		ret = macvtap_disable_queue(q);
+	else
+		ret = -EINVAL;
 
 	macvtap_put_vlan(vlan);
 	return ret;
Signature · 1 line
1.7.1
#2 lore raw
In reply to Jason Wang
Quoted 14 lines · Jason Wang

This patch silents the following sparse warnings:

dr

---
 drivers/net/macvtap.c      |    2 +-
 include/linux/if_macvlan.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/macvtap.c +0 -0
index 992151c..acf55ba 100644

drivers/net/macvtap.c static int macvtap_open(struct inode *inode, struct file *file) · line 432

Quoted 5 lines
drivers/net/macvtap.c +1 -1
@@ -429,7 +429,7 @@ static int macvtap_open(struct inode *inode, struct file *file)
 	if (!q)
 		goto out;
 
-	q->sock.wq = &q->wq;
+	rcu_assign_pointer(q->sock.wq, &q->wq);

Since nobody but you [1] can access this object at that time, you could rather use

	RCU_INIT_POINTER(q->sock.wq, &q->wq);

rcu_assign_pointer() is also a documentation point (memory barrier)

By using RCU_INIT_POINTER() you clearly show that you know you need no memory barrier.

drivers/net/macvtap.c static int macvtap_open(struct inode *inode, struct file *file) · line 433

Quoted 1 line
drivers/net/macvtap.c +0 -0
 	init_waitqueue_head(&q->wq.wait);

[1] :
or else, this init_waitqueue_head() should be done _before_ the rcu_asign_pointer()

Quoted 2 lines
drivers/net/macvtap.c +0 -0
 	q->sock.type = SOCK_RAW;
 	q->sock.state = SS_CONNECTED;
author
#3 lore raw
Quoted 22 lines · Eric Dumazet
Quoted 14 lines · Jason Wang

This patch silents the following sparse warnings:

dr

---
 drivers/net/macvtap.c      |    2 +-
 include/linux/if_macvlan.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/macvtap.c +0 -0
index 992151c..acf55ba 100644

drivers/net/macvtap.c static int macvtap_open(struct inode *inode, struct file *file) · line 432

Quoted 5 lines
drivers/net/macvtap.c +1 -1
@@ -429,7 +429,7 @@ static int macvtap_open(struct inode *inode, struct file *file)
 	if (!q)
 		goto out;
 
-	q->sock.wq = &q->wq;
+	rcu_assign_pointer(q->sock.wq, &q->wq);

Since nobody but you [1] can access this object at that time, you could rather use

Quoted 7 lines
	RCU_INIT_POINTER(q->sock.wq, &q->wq);

rcu_assign_pointer() is also a documentation point (memory barrier)

By using RCU_INIT_POINTER() you clearly show that you know you need no memory barrier.

True.

Quoted 4 lines

drivers/net/macvtap.c static int macvtap_open(struct inode *inode, struct file *file) · line 433

Quoted 1 line
drivers/net/macvtap.c +0 -0
 	init_waitqueue_head(&q->wq.wait);

[1] :
or else, this init_waitqueue_head() should be done _before_ the rcu_asign_pointer()

Thanks, I will send v2 by using RCU_INIT_POINTER().

Quoted 8 lines

drivers/net/macvtap.c static int macvtap_open(struct inode *inode, struct file *file) · line 435

Quoted 3 lines
drivers/net/macvtap.c +0 -0
 	q->sock.type = SOCK_RAW;
 	q->sock.state = SS_CONNECTED;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html