* [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query
@ 2026-05-25 9:54 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-05-25 9:54 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Amir Goldstein, Tim Bird, Christian Brauner
Cc: Thorsten Blum, netdev, linux-kernel
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 <thorsten.blum@linux.dev>
---
net/dns_resolver/dns_query.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c
index e1c09d7b8200..c250d82cad96 100644
--- a/net/dns_resolver/dns_query.c
+++ b/net/dns_resolver/dns_query.c
@@ -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);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-25 9:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25 9:54 [PATCH net-next] net/dns_resolver: consolidate namelen checks in dns_query Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox