[Devel,2/6] venet: treat presence of veip object with the same VEID as error

Submitted by Stanislav Kinsburskiy on April 21, 2017, 3:04 p.m.

Details

Message ID 20170421150427.31147.74342.stgit@localhost.localdomain
State New
Series "Fix VEIP object handling on container destroy"
Headers show

Commit Message

Stanislav Kinsburskiy April 21, 2017, 3:04 p.m.
This shouldn't happen. VEIP object is identified by veid, which is unique per
VE structure.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 drivers/net/veip_mgmt.c |    2 ++
 drivers/net/venetdev.c  |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/net/veip_mgmt.c b/drivers/net/veip_mgmt.c
index 343ee7d..b45e411 100644
--- a/drivers/net/veip_mgmt.c
+++ b/drivers/net/veip_mgmt.c
@@ -42,6 +42,8 @@  static int veip_create(struct ve_struct *ve)
 	veip = veip_findcreate(ve->veid);
 	if (veip == NULL)
 		return -ENOMEM;
+	if (IS_ERR(veip))
+		return PTR_ERR(veip);
 
 	ve->veip = veip;
 	return 0;
diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
index a4388fd..192ca3c 100644
--- a/drivers/net/venetdev.c
+++ b/drivers/net/venetdev.c
@@ -221,7 +221,7 @@  struct veip_struct *veip_findcreate(envid_t veid)
 
 	ptr = veip_find(veid);
 	if (ptr != NULL)
-		return ptr;
+		return ERR_PTR(-EEXIST);
 
 	ptr = kmalloc(sizeof(struct veip_struct), GFP_ATOMIC);
 	if (ptr == NULL)