Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ieee802154: fix faulty check in set_phy_params api

phy_set_csma_params has a redundant (and impossible) check for
"retries", found by smatch. The check was supposed to be for
frame_retries, but wasn't moved during development when
phy_set_frame_retries was introduced. Also, maxBE >= 3 as required by
the standard is not enforced.

Remove the redundant check, assure max_be >= 3 and check -1 <=
frame_retries <= 7 in the correct function.

Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Phoebe Buckheister and committed by
David S. Miller
1c8272bd 9e5f040d

+4 -2
+4 -2
net/ieee802154/nl-phy.c
··· 436 436 if (info->attrs[IEEE802154_ATTR_CSMA_MAX_BE]) 437 437 max_be = nla_get_u8(info->attrs[IEEE802154_ATTR_CSMA_MAX_BE]); 438 438 439 - if (retries > 5 || max_be > 8 || min_be > max_be || 440 - retries < -1 || retries > 7) 439 + if (retries > 5 || max_be < 3 || max_be > 8 || min_be > max_be) 441 440 return -EINVAL; 442 441 443 442 rc = phy->set_csma_params(phy, min_be, max_be, retries); ··· 454 455 { 455 456 s8 retries = nla_get_s8(info->attrs[IEEE802154_ATTR_FRAME_RETRIES]); 456 457 int rc; 458 + 459 + if (retries < -1 || retries > 7) 460 + return -EINVAL; 457 461 458 462 rc = phy->set_frame_retries(phy, retries); 459 463 if (rc < 0)