FROMLIST: bootconfig: Share the checksum function with tools

Move the checksum calculation function into the header for sharing it
with tools/bootconfig.

Picking this up FROMLIST to get the fix ASAP. It is likely to be
accepted upstream.

Signed-off-by: Devin Moore <devinmoore@google.com>
Link: https://lore.kernel.org/lkml/162262192121.264090.6540508908529705156.stgit@devnote2/
Bug: 183237066
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Change-Id: Ifd79a0fc7d75bde733ffe8f979c7e30e4c5844c7
This commit is contained in:
Masami Hiramatsu
2021-06-02 17:19:34 +09:00
committed by Devin Moore
parent 88fa7f8bf0
commit cdd895c318
3 changed files with 23 additions and 24 deletions

View File

@@ -388,16 +388,6 @@ static char * __init xbc_make_cmdline(const char *key)
return new_cmdline;
}
static u32 boot_config_checksum(unsigned char *p, u32 size)
{
u32 ret = 0;
while (size--)
ret += *p++;
return ret;
}
static int __init bootconfig_params(char *param, char *val,
const char *unused, void *arg)
{
@@ -441,7 +431,7 @@ static void __init setup_boot_config(const char *cmdline)
return;
}
if (boot_config_checksum((unsigned char *)data, size) != csum) {
if (xbc_calc_checksum(data, size) != csum) {
pr_err("bootconfig checksum failed\n");
return;
}