mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-26 12:27:12 +00:00
usb: gadget: ci: Avoid null pointer dereference
The ci_req->hw_buf can be NULL, test whether it is and if so, avoid accessing it. Else, the system may crash. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Peter Chen <peter.chen@nxp.com> Cc: Li Jun <jun.li@nxp.com> Cc: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
parent
96991e652f
commit
1f54025d70
1 changed files with 4 additions and 1 deletions
|
@ -402,6 +402,9 @@ align:
|
||||||
|
|
||||||
flush:
|
flush:
|
||||||
hwaddr = (unsigned long)ci_req->hw_buf;
|
hwaddr = (unsigned long)ci_req->hw_buf;
|
||||||
|
if (!hwaddr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
aligned_used_len = roundup(req->length, ARCH_DMA_MINALIGN);
|
aligned_used_len = roundup(req->length, ARCH_DMA_MINALIGN);
|
||||||
flush_dcache_range(hwaddr, hwaddr + aligned_used_len);
|
flush_dcache_range(hwaddr, hwaddr + aligned_used_len);
|
||||||
|
|
||||||
|
@ -415,7 +418,7 @@ static void ci_debounce(struct ci_req *ci_req, int in)
|
||||||
unsigned long hwaddr = (unsigned long)ci_req->hw_buf;
|
unsigned long hwaddr = (unsigned long)ci_req->hw_buf;
|
||||||
uint32_t aligned_used_len;
|
uint32_t aligned_used_len;
|
||||||
|
|
||||||
if (in)
|
if (in || !hwaddr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
aligned_used_len = roundup(req->actual, ARCH_DMA_MINALIGN);
|
aligned_used_len = roundup(req->actual, ARCH_DMA_MINALIGN);
|
||||||
|
|
Loading…
Add table
Reference in a new issue