From b1adc08178c7ec669522ddc8a7a777baf1224b01 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 20 Aug 2024 14:04:12 +0200 Subject: [PATCH] bootcount: fix segfault by checking the funcs are not NULL Signed-off-by: Hector Palacios --- .../bootcount/bootcount/bootcount-bin/bootcount.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount.c b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount.c index 55dc5fe76..07845a486 100644 --- a/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount.c +++ b/meta-digi-dey/recipes-digi/bootcount/bootcount/bootcount-bin/bootcount.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include @@ -162,6 +163,11 @@ int main(int argc, char *argv[]) { /* Determine platform. */ platform = get_platform(); pfuncs = &platforms_functions[platform]; + if (!pfuncs->read_bootcount || !pfuncs->write_bootcount) { + printf("Platform not supported\n"); + ret = -ENOTSUP; + goto end; + } /* Execute the requested action. */ if (read) { @@ -176,5 +182,6 @@ int main(int argc, char *argv[]) { ret = pfuncs->write_bootcount(0); } +end: return ret; }