Skip to contentSkip to conversation

net/dns_resolver: consolidate namelen checks in dns_query

PATCH Applied Thorsten Blum 3 participants 3 messages May 25 – May 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

---
 net/dns_resolver/dns_query.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/dns_resolver/dns_query.c +1 -3
index e1c09d7b8200..c250d82cad96 100644
@@ -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);
#2 lore raw
In reply to Thorsten Blum
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 -EINVAL early if needed. Drop the namelen == 0 check since it is covered by namelen < 3.

---
 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