net: Check device driver API pointer
It is possible that the device driver API pointer is null. For example if the device driver returns an error, the device code will make the API pointer NULL so that the API would not be used. This can cause errors in networking code where we typically do not check the NULL value. Fixes #15003 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
9a6e3012da
commit
9a6bbbfb69
9 changed files with 97 additions and 18 deletions
|
@ -354,7 +354,7 @@ static int can_sock_getsockopt_vmeth(void *obj, int level, int optname,
|
|||
dev = net_if_get_device(iface);
|
||||
api = dev->driver_api;
|
||||
|
||||
if (!api->getsockopt) {
|
||||
if (!api || !api->getsockopt) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ static int can_sock_setsockopt_vmeth(void *obj, int level, int optname,
|
|||
dev = net_if_get_device(iface);
|
||||
api = dev->driver_api;
|
||||
|
||||
if (!api->setsockopt) {
|
||||
if (!api || !api->setsockopt) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue