[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bc92582d5de175ec325ae53ed3fe18a5e073438b.camel@sipsolutions.net>
Date: Wed, 04 Feb 2026 09:36:29 +0100
From: Johannes Berg <johannes@...solutions.net>
To: Sun Jian <sun.jian.kdev@...il.com>
Cc: linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] wifi: nl80211: drop impossible negative band check
On Wed, 2026-02-04 at 16:18 +0800, Sun Jian wrote:
> band is derived from nla_type() of a nested netlink attribute, which is
> a masked u16 value and therefore cannot be negative. Drop the dead
> "band < 0" checks and keep the upper bound validation.
I've seen this before, but I'm not really convinced it is entirely
correct. C says:
All enumerations have an underlying type. The underlying type can be
explicitly specified using an enum type specifier and is its fixed
underlying type. If it is not explicitly specified, the underlying
type is the enumeration’s compatible type, which is either char or a
standard or extended signed or unsigned integer type.
It would thus _seem_ to be possible for an enum to generally be a signed
type, and therefore a 'signed short', and therefore an nla_type() that's
a u16 could end up with a negative value...
Am I wrong?
johannes
Powered by blists - more mailing lists