diff options
| author | Thorsten Blum <thorsten.blum@linux.dev> | 2026-05-25 11:54:01 +0200 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-05-27 17:00:44 -0700 |
| commit | f289c0664f64578355d10a85a6e0108fd182043c (patch) | |
| tree | 02a22567cc59580f9b319e47406878d30c656a49 /net | |
| parent | aa064a614efcfa4c300609d1f01134e99a12ad10 (diff) | |
| download | linux-next-history-f289c0664f64578355d10a85a6e0108fd182043c.tar.gz | |
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 <thorsten.blum@linux.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260525095400.821912-3-thorsten.blum@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
| -rw-r--r-- | net/dns_resolver/dns_query.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index e1c09d7b82007..c250d82cad965 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); |
