net/dns_resolver: consolidate namelen checks in dns_query
Subsystems (2)
PATCH 1/1 net/dns_resolver: consolidate namelen checks in dns_query
Consolidate the namelen checks and return -EINVAL early if needed. Drop the namelen == 0 check since it is covered by namelen < 3.
Signed-off-by Thorsten Blum <[email protected]>
--- net/dns_resolver/dns_query.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/dns_resolver/dns_query.c +1 -3
@@ -73,7 +73,7 @@ int dns_query(struct net *net,kenter ("%s,%*.*s,%zu,%s" , type, (int )namelen, (int )namelen, name, namelen, options); -if (!name || namelen ==0 ) +if (!name || namelen <3 || namelen >255 )return -EINVAL ;/* construct the query key description as "[<type>:]<name>" */
@@ -86,8 +86,6 @@ int dns_query(struct net *net, desclen += typelen +1 ; } -if (namelen <3 || namelen >255 ) -return -EINVAL ; desclen += namelen +1 ; desc =kmalloc (desclen,GFP_KERNEL );
Quoted 4 lines · Thorsten Blum
Consolidate the namelen checks and return
-EINVALearly if needed. Drop the namelen == 0 check since it is covered by namelen < 3.Signed-off-by Thorsten Blum <[email protected]>
Reviewed-by Simon Horman <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 7 lines · On Mon, 25 May 2026 11:54:01 +0200 you wrote:
Consolidate the namelen checks and return
-EINVALearly if needed. Drop the namelen == 0 check since it is covered by namelen < 3.Signed-off-by Thorsten Blum <[email protected]>--- net/dns_resolver/dns_query.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Here is the summary with links:
- [net-next] net/dns_resolver: consolidate namelen checks in dns_query
https://git.kernel.org/netdev/net-next/c/f289c0664f64
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html