Skip to content

Commit 68fe1db

Browse files
Alexander AringStefan-Schmidt
authored andcommitted
net: ieee802154: return -EINVAL for unknown addr type
This patch adds handling to return -EINVAL for an unknown addr type. The current behaviour is to return 0 as successful but the size of an unknown addr type is not defined and should return an error like -EINVAL. Fixes: 9416010 ("net/ieee802154: fix uninit value bug in dgram_sendmsg") Signed-off-by: Alexander Aring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]>
1 parent 1d22f78 commit 68fe1db

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

include/net/ieee802154_netdev.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,27 @@ static inline int
185185
ieee802154_sockaddr_check_size(struct sockaddr_ieee802154 *daddr, int len)
186186
{
187187
struct ieee802154_addr_sa *sa;
188+
int ret = 0;
188189

189190
sa = &daddr->addr;
190191
if (len < IEEE802154_MIN_NAMELEN)
191192
return -EINVAL;
192193
switch (sa->addr_type) {
194+
case IEEE802154_ADDR_NONE:
195+
break;
193196
case IEEE802154_ADDR_SHORT:
194197
if (len < IEEE802154_NAMELEN_SHORT)
195-
return -EINVAL;
198+
ret = -EINVAL;
196199
break;
197200
case IEEE802154_ADDR_LONG:
198201
if (len < IEEE802154_NAMELEN_LONG)
199-
return -EINVAL;
202+
ret = -EINVAL;
203+
break;
204+
default:
205+
ret = -EINVAL;
200206
break;
201207
}
202-
return 0;
208+
return ret;
203209
}
204210

205211
static inline void ieee802154_addr_from_sa(struct ieee802154_addr *a,

0 commit comments

Comments
 (0)