Skip to contentSkip to conversation

net/enic: check notify set return value during init

PATCH Superseded Alexey Simakov 2 participants 6 messages Jul 15 – Jul 20 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/enic: check notify set return value during init

The return value of vnic_dev_notify_set() is silently ignored in enic_dev_init(), so a memory allocation failure or hardware command error goes unnoticed and the driver continues with uninitialized notification state.

Check the return value and propagate the error to abort probe when notification setup fails.

Fixes fefed3d1e62c ("enic: new driver")

---
v2 changes: validate return code of vnic_dev_notify_set() in driver init section
v1 link:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

 drivers/net/enic/enic_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/enic/enic_main.c +3 -1
index 2696fa77d4..f46f429135 100644
@@ -1887,7 +1887,9 @@ static int enic_dev_init(struct enic *enic)
 	LIST_INIT(&enic->flows);
 
 	/* set up link status checking */
-	vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	err = vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	if (err)
+		return err;
 
 	enic->overlay_offload = false;
 	/*
Signature · 1 line
2.34.1
#1 lore raw
Quoted 38 lines

-----Original Message-----
From: Alexey Simakov <[email protected]>
Sent: Wednesday, July 15, 2026 7:31 PM
To: John Daley (johndale) <[email protected]>; Hyong Youb Kim (hyonkim) <[email protected]>; Neil Horman <[email protected]>; Sujith Sankar <[email protected]>; David Marchand <[email protected]>
Cc: [email protected]; [email protected]; Alexey Simakov <[email protected]>
Subject: [PATCH v2] net/enic: check notify set return value during init

The return value of vnic_dev_notify_set() is silently ignored in enic_dev_init(), so a memory allocation failure or hardware command error goes unnoticed and the driver continues with uninitialized notification state.

Check the return value and propagate the error to abort probe when notification setup fails.

Fixes fefed3d1e62c ("enic: new driver")

---
v2 changes: validate return code of vnic_dev_notify_set() in driver init section
v1 link:
https://patches.dpdk.org/project/dpdk/patch/20260707112014.82821-1-
[email protected]/

 drivers/net/enic/enic_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/enic/enic_main.c +0 -0
index 2696fa77d4..f46f429135 100644

drivers/net/enic/enic_main.c static int enic_dev_init(struct enic *enic) · line 1893

Quoted 8 lines
drivers/net/enic/enic_main.c +3 -1
@@ -1887,7 +1887,9 @@ static int enic_dev_init(struct enic *enic)
 	LIST_INIT(&enic->flows);
 
 	/* set up link status checking */
-	vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	err = vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	if (err)
+		return err;
 

Could you add an error message, like the following? Looks like all error returns in this function log a message.

dev_err(enic, "failed to enable notify buffer\n");

Thanks.
-Hyong

Quoted 4 lines
drivers/net/enic/enic_main.c +0 -1
 	enic->overlay_offload = false;
 	/*
--

2.34.1

#2 lore raw

Sure, also dpdk ai review higlightet potential problems in memory management

For example:

enic->cq = rte_zmalloc("enic_vnic_cq", sizeof(struct vnic_cq) *

			       enic->conf_cq_count, 8);
enic->intr = rte_zmalloc("enic_vnic_intr", sizeof(struct vnic_intr) *
			enic->conf_intr_count, 8);
enic->rq = rte_zmalloc("enic_vnic_rq", sizeof(struct vnic_rq) *
			enic->conf_rq_count, 8);
enic->wq = rte_zmalloc("enic_vnic_wq", sizeof(struct vnic_wq) *
			enic->conf_wq_count, 8);
if (enic->conf_cq_count > 0 && enic->cq == NULL) {
	dev_err(enic, "failed to allocate vnic_cq, aborting.\n");
	return -1;
}
if (enic->conf_intr_count > 0 && enic->intr == NULL) {
	dev_err(enic, "failed to allocate vnic_intr, aborting.\n");
	return -1;
}

Lets imagine that enic->cq is allocated successfully, after that when we trying to allocate enic->intr we are failing, so in this case we leaking in second if statement, this related to all error handling paths in driver, since as far as I understand resource free happening only in enic_dev_deinit(...) function.

So my question is it problem? If yes, should I address this issue in scope of my patch or better to make it in another?

#3 lore raw
Quoted 34 lines

-----Original Message-----
From: Alexey Simakov <[email protected]>
Sent: Friday, July 17, 2026 6:23 PM
To: Hyong Youb Kim (hyonkim) <[email protected]>
Cc: John Daley (johndale) <[email protected]>; Neil Horman <[email protected]>; Sujith Sankar <[email protected]>; David Marchand <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v2] net/enic: check notify set return value during init

Sure, also dpdk ai review higlightet potential problems in memory management

For example:

enic->cq = rte_zmalloc("enic_vnic_cq", sizeof(struct vnic_cq) *

			       enic->conf_cq_count, 8);
enic->intr = rte_zmalloc("enic_vnic_intr", sizeof(struct vnic_intr) *
			enic->conf_intr_count, 8);
enic->rq = rte_zmalloc("enic_vnic_rq", sizeof(struct vnic_rq) *
			enic->conf_rq_count, 8);
enic->wq = rte_zmalloc("enic_vnic_wq", sizeof(struct vnic_wq) *
			enic->conf_wq_count, 8);
if (enic->conf_cq_count > 0 && enic->cq == NULL) {
	dev_err(enic, "failed to allocate vnic_cq, aborting.\n");
	return -1;
}
if (enic->conf_intr_count > 0 && enic->intr == NULL) {
	dev_err(enic, "failed to allocate vnic_intr, aborting.\n");
	return -1;
}
Quoted 8 lines

Lets imagine that enic->cq is allocated successfully, after that when we trying to allocate enic->intr we are failing, so in this case we leaking in second if statement, this related to all error handling paths in driver, since as far as I understand resource free happening only in enic_dev_deinit(...) function.

So my question is it problem? If yes, should I address this issue in scope of my patch or better to make it in another?

Why don't you create one cleanup patch that addresses both issues, since they are in the same function?

Thanks.
-Hyong

#4 lore raw

PATCH v3 1/1 net/enic: check notify set return value during init

The return value of vnic_dev_notify_set() is silently ignored in enic_dev_init(), so a memory allocation failure or hardware command error goes unnoticed and the driver continues with uninitialized notification state.

Check the return value and propagate the error to abort probe when notification setup fails.

Fixes fefed3d1e62c ("enic: new driver")

---

v3 changes: add log message

v2 link: https://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2 changes: validate return code of vnic_dev_notify_set() in driver init section

v1 link: https://patches.dpdk.org/project/dpdk/patch/[email protected]/

 drivers/net/enic/enic_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/enic/enic_main.c +5 -1
index 2696fa77d4..2a1a65d8da 100644
@@ -1887,7 +1887,11 @@ static int enic_dev_init(struct enic *enic)
 	LIST_INIT(&enic->flows);
 
 	/* set up link status checking */
-	vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	err = vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	if (err) {
+		dev_err(enic, "failed to enable notify buffer\n");
+		return err;
+	}
 
 	enic->overlay_offload = false;
 	/*
Signature · 1 line
2.53.0
Acked-by on v3 1/1
#5 lore raw
Quoted 42 lines

-----Original Message-----
From: Alexey Simakov <[email protected]>
Sent: Monday, July 20, 2026 6:34 PM
To: Hyong Youb Kim (hyonkim) <[email protected]>
Cc: [email protected]; [email protected]; John Daley (johndale) <[email protected]>; [email protected]; [email protected]; Alexey Simakov <[email protected]>
Subject: [PATCH v3] net/enic: check notify set return value during init

The return value of vnic_dev_notify_set() is silently ignored in enic_dev_init(), so a memory allocation failure or hardware command error goes unnoticed and the driver continues with uninitialized notification state.

Check the return value and propagate the error to abort probe when notification setup fails.

Fixes fefed3d1e62c ("enic: new driver")

---

v3 changes: add log message

v2 link: https://patches.dpdk.org/project/dpdk/patch/20260715103105.39417-
[email protected]/
v2 changes: validate return code of vnic_dev_notify_set() in driver init section

v1 link: https://patches.dpdk.org/project/dpdk/patch/20260707112014.82821-
[email protected]/

 drivers/net/enic/enic_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/enic/enic_main.c +0 -0
index 2696fa77d4..2a1a65d8da 100644

drivers/net/enic/enic_main.c static int enic_dev_init(struct enic *enic) · line 1895

Quoted 10 lines
drivers/net/enic/enic_main.c +5 -1
@@ -1887,7 +1887,11 @@ static int enic_dev_init(struct enic *enic)
 	LIST_INIT(&enic->flows);
 
 	/* set up link status checking */
-	vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	err = vnic_dev_notify_set(enic->vdev, -1); /* No Intr for notify */
+	if (err) {
+		dev_err(enic, "failed to enable notify buffer\n");
+		return err;
+	}
 

Thanks.
-Hyong

Quoted 4 lines
drivers/net/enic/enic_main.c +0 -1
 	enic->overlay_offload = false;
 	/*
--

2.53.0