In mtd_replace_jffs2(), the return value of malloc(erasesize) is never checked. If the allocation fails, buf remains NULL and the subsequent memcpy(buf + ofs, ...) in add_data() will dereference NULL, causing a segfault. Add a NULL check and return -1 on allocation failure. Match the diagnostic message used by the sibling mtd_write_jffs2() so the out-of-memory cause is visible at the call site. Signed-off-by: Anna Kiri <bredcorn@gmail.com> Link: https://github.com/openwrt/openwrt/pull/23553 Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> |
||
|---|---|---|
| .. | ||
| base-files | ||
| boot | ||
| devel | ||
| firmware | ||
| kernel | ||
| libs | ||
| network | ||
| system | ||
| utils | ||
| Makefile | ||