* [PATCH] devlink: add NULL check in devlink_dpipe_entry_clear
@ 2025-10-29 7:02 Zhang Chujun
2025-10-29 17:32 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Chujun @ 2025-10-29 7:02 UTC (permalink / raw)
To: przemyslaw.kitszel; +Cc: devlink, netdev, Zhang Chujun
This patch adds a NULL check for the pointer 'entry' at the entry
point of the function devlink_pipe_entry_clear. If the passed
'entry' is NULL, the function returns immediately, avoiding subsequent
dereferencing of a NULL pointer and thus preventing potential kernel
crahses or segmentation faults.
Signed-off-by: Zhang Chujun <zhangchujun@cmss.chinamobile.com>
diff --git a/net/devlink/dpipe.c b/net/devlink/dpipe.c
index e55701b007f0..4517d5112311 100644
--- a/net/devlink/dpipe.c
+++ b/net/devlink/dpipe.c
@@ -514,6 +514,9 @@ void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry)
unsigned int value_count, value_index;
struct devlink_dpipe_value *value;
+ if (!entry)
+ return;
+
value = entry->action_values;
value_count = entry->action_values_count;
for (value_index = 0; value_index < value_count; value_index++) {
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] devlink: add NULL check in devlink_dpipe_entry_clear
2025-10-29 7:02 [PATCH] devlink: add NULL check in devlink_dpipe_entry_clear Zhang Chujun
@ 2025-10-29 17:32 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2025-10-29 17:32 UTC (permalink / raw)
To: Zhang Chujun; +Cc: przemyslaw.kitszel, devlink, netdev
On Wed, Oct 29, 2025 at 03:02:56PM +0800, Zhang Chujun wrote:
> This patch adds a NULL check for the pointer 'entry' at the entry
> point of the function devlink_pipe_entry_clear. If the passed
> 'entry' is NULL, the function returns immediately, avoiding subsequent
> dereferencing of a NULL pointer and thus preventing potential kernel
> crahses or segmentation faults.
>
> Signed-off-by: Zhang Chujun <zhangchujun@cmss.chinamobile.com>
Hi,
Do you have a case where entry can be NULL?
If not, this feels like defensive programming,
which, AFAIK, is not the preferred approach for Kernel code.
...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-29 17:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29 7:02 [PATCH] devlink: add NULL check in devlink_dpipe_entry_clear Zhang Chujun
2025-10-29 17:32 ` Simon Horman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.