[PATCH net-next 1/4] netconsole: Warn if MAX_USERDATA_ITEMS limit is exceeded

Breno Leitao posted 4 patches 1 year ago
There is a newer version of this series
[PATCH net-next 1/4] netconsole: Warn if MAX_USERDATA_ITEMS limit is exceeded
Posted by Breno Leitao 1 year ago
netconsole configfs helpers doesn't allow the creation of more than
MAX_USERDATA_ITEMS items.

Add a warning when netconsole userdata update function attempts sees
more than MAX_USERDATA_ITEMS entries.

Replace silent ignore mechanism with WARN_ON_ONCE() to highlight
potential misuse during development and debugging.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 4ea44a2f48f7b1f9059d275f0f0edc40cc1997f0..8b9dd4842f3e516c7eaa08205a45092e64417440 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -705,7 +705,7 @@ static void update_userdata(struct netconsole_target *nt)
 		struct userdatum *udm_item;
 		struct config_item *item;
 
-		if (child_count >= MAX_USERDATA_ITEMS)
+		if (WARN_ON_ONCE(child_count >= MAX_USERDATA_ITEMS))
 			break;
 		child_count++;
 

-- 
2.43.5
Re: [PATCH net-next 1/4] netconsole: Warn if MAX_USERDATA_ITEMS limit is exceeded
Posted by Simon Horman 1 year ago
On Wed, Dec 04, 2024 at 08:40:42AM -0800, Breno Leitao wrote:
> netconsole configfs helpers doesn't allow the creation of more than
> MAX_USERDATA_ITEMS items.
> 
> Add a warning when netconsole userdata update function attempts sees
> more than MAX_USERDATA_ITEMS entries.
> 
> Replace silent ignore mechanism with WARN_ON_ONCE() to highlight
> potential misuse during development and debugging.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Simon Horman <horms@kernel.org>