From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/2] lib: jsmn: fix compilation error
Date: Wed, 11 Sep 2024 13:13:17 +0200 [thread overview]
Message-ID: <20240911111318.2963525-1-a.fatoum@pengutronix.de> (raw)
With recent restructuring of the headers, kmalloc_array was no longer
indirectly included, which broke the build.
Add the missing headers and while at it switch over to normal malloc,
because kmalloc_array() uses a bigger alignment than necessary.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
lib/jsmn.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/jsmn.c b/lib/jsmn.c
index 10a77886a8bd..10ef349fa122 100644
--- a/lib/jsmn.c
+++ b/lib/jsmn.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <stdio.h>
#include <jsmn.h>
+#include <linux/overflow.h>
+#include <malloc.h>
/**
* Allocates a fresh unused token from the token pool.
@@ -391,7 +393,7 @@ JSMN_API jsmntok_t *jsmn_parse_alloc(const char *js, const size_t len,
token_count = ret;
- tokens = kmalloc_array(token_count, sizeof(jsmntok_t), GFP_KERNEL);
+ tokens = malloc(size_mul(token_count, sizeof(jsmntok_t)));
if (!tokens)
return NULL;
--
2.39.2
next reply other threads:[~2024-09-11 11:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 11:13 Ahmad Fatoum [this message]
2024-09-11 11:13 ` [PATCH master 2/2] include: stdlib.h: define prototypes for malloc/free Ahmad Fatoum
2024-09-13 6:32 ` [PATCH master 1/2] lib: jsmn: fix compilation error Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240911111318.2963525-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox