summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPrasad Kummari <[email protected]>2024-09-13 13:02:52 +0530
committerTom Rini <[email protected]>2024-09-20 17:38:16 -0600
commit33a4dfc703b43f0e8d4da76411ee3f5aee0c8033 (patch)
tree32e79968e175f9b967e8c5d926aea196d861ce58 /include
parent948616894c6d3316a5ac8f2a891783e3e7ff3516 (diff)
cmd: sf: prevent overwriting the reserved memory
Added LMB API to prevent SF command from overwriting reserved memory areas. The current SPI code does not use LMB APIs for loading data into memory addresses. To resolve this, LMB APIs were added to check the load address of an SF command and ensure it does not overwrite reserved memory addresses. Similar checks are used in TFTP, serial load, and boot code to prevent overwriting reserved memory. Signed-off-by: Prasad Kummari <[email protected]> Suggested-by: Sughosh Ganu <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/lmb.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/lmb.h b/include/lmb.h
index fc2daaa7bfc..aee2f9fcdaa 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -111,6 +111,11 @@ struct lmb *lmb_get(void);
int lmb_push(struct lmb *store);
void lmb_pop(struct lmb *store);
+static inline int lmb_read_check(phys_addr_t addr, phys_size_t len)
+{
+ return lmb_alloc_addr(addr, len) == addr ? 0 : -1;
+}
+
#endif /* __KERNEL__ */
#endif /* _LINUX_LMB_H */