Subject: [PATCH net-next 2/3] switchdev: fix: pass correct obj size when deferring obj add

From: [email-masked]
Date: Tue, 20 Oct 2015 12:36:38 -0700

From: Scott Feldman <[email-masked]>

Fixes: 0bc05d585d ("switchdev: allow caller to explicitly request attr_set as deferred")
Signed-off-by: Scott Feldman <[email-masked]>
---
 net/switchdev/switchdev.c |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 56d8479..be8ced1 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -489,7 +489,24 @@ static void switchdev_port_obj_del_deferred(struct net_device *dev,
 static int switchdev_port_obj_del_defer(struct net_device *dev,
 					const struct switchdev_obj *obj)
 {
-	return switchdev_deferred_enqueue(dev, obj, sizeof(*obj),
+	size_t size = 0;
+
+	switch (obj->id) {
+	case SWITCHDEV_OBJ_ID_PORT_VLAN:
+		size = sizeof(struct switchdev_obj_port_vlan);
+		break;
+	case SWITCHDEV_OBJ_ID_IPV4_FIB:
+		size = sizeof(struct switchdev_obj_ipv4_fib);
+		break;
+	case SWITCHDEV_OBJ_ID_PORT_FDB:
+		size = sizeof(struct switchdev_obj_port_fdb);
+		break;
+	default:
+		WARN_ON(!size);
+		return -EINVAL;
+	}
+
+	return switchdev_deferred_enqueue(dev, obj, size,
 					  switchdev_port_obj_del_deferred);
 }
 
-- 
1.7.10.4