drivers: udc: avoid NULL pointer dereferencing if endpoint is invalid
Immediately return NULL if endpoint configuration is not available. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
e9bab613cc
commit
c1860326d1
1 changed files with 3 additions and 2 deletions
|
@ -121,10 +121,11 @@ struct net_buf *udc_buf_peek(const struct device *dev, const uint8_t ep,
|
|||
struct net_buf *buf = NULL;
|
||||
|
||||
ep_cfg = udc_get_ep_cfg(dev, ep);
|
||||
if (ep_cfg != NULL) {
|
||||
buf = k_fifo_peek_head(&ep_cfg->fifo);
|
||||
if (ep_cfg == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf = k_fifo_peek_head(&ep_cfg->fifo);
|
||||
if (buf == NULL && pending) {
|
||||
ep_cfg->stat.pending = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue