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

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Fri Apr 21 08:04:27 PDT 2017


This shouldn't happen. VEIP object is identified by veid, which is unique per
VE structure.

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

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)



More information about the Devel mailing list