Merge pull request #15824 from maribu/at86rf2xx-fix-null-ptr-check

drivers/at86rf2xx: fix null pointer check
This commit is contained in:
Marian Buschsieweke 2021-01-21 12:18:53 +01:00 committed by GitHub
commit d28f74d301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,7 +305,7 @@ netopt_state_t _get_state(at86rf2xx_t *dev)
static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len) static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
{ {
at86rf2xx_t *dev = (at86rf2xx_t *) netdev; at86rf2xx_t *dev = (at86rf2xx_t *)netdev;
if (netdev == NULL) { if (netdev == NULL) {
return -ENODEV; return -ENODEV;
@ -483,13 +483,12 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len) static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
{ {
at86rf2xx_t *dev = (at86rf2xx_t *) netdev; at86rf2xx_t *dev = (at86rf2xx_t *)netdev;
uint8_t old_state = at86rf2xx_get_status(dev);
int res = -ENOTSUP;
if (dev == NULL) { if (dev == NULL) {
return -ENODEV; return -ENODEV;
} }
uint8_t old_state = at86rf2xx_get_status(dev);
int res = -ENOTSUP;
/* temporarily wake up if sleeping and opt != NETOPT_STATE. /* temporarily wake up if sleeping and opt != NETOPT_STATE.
* opt != NETOPT_STATE check prevents redundant wake-up. * opt != NETOPT_STATE check prevents redundant wake-up.