Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29b376ff authored by Franck Bui-Huu's avatar Franck Bui-Huu Committed by Ralf Baechle
Browse files

[MIPS] get_frame_info(): null function size means size is unknown



This patch adds 2 sanity checks.

The first one test that the start address of the function to analyze has been
set by the caller. If not return an error since nothing usefull can be done
without.

The second one checks that the function's size has been set. A null size can
happen if CONFIG_KALLSYMS is not set and it means that we don't know the size
of the function to analyze. In this case, we make it equal to 128 instructions
by default.

Signed-off-by: default avatarFranck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 1fd69098
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -311,12 +311,19 @@ static inline int is_sp_move_ins(union mips_instruction *ip)
static int get_frame_info(struct mips_frame_info *info)
static int get_frame_info(struct mips_frame_info *info)
{
{
	union mips_instruction *ip = info->func;
	union mips_instruction *ip = info->func;
	int i, max_insns =
	unsigned max_insns = info->func_size / sizeof(union mips_instruction);
		min(128UL, info->func_size / sizeof(union mips_instruction));
	unsigned i;


	info->pc_offset = -1;
	info->pc_offset = -1;
	info->frame_size = 0;
	info->frame_size = 0;


	if (!ip)
		goto err;

	if (max_insns == 0)
		max_insns = 128U;	/* unknown function size */
	max_insns = min(128U, max_insns);

	for (i = 0; i < max_insns; i++, ip++) {
	for (i = 0; i < max_insns; i++, ip++) {


		if (is_jal_jalr_jr_ins(ip))
		if (is_jal_jalr_jr_ins(ip))
@@ -337,6 +344,7 @@ static int get_frame_info(struct mips_frame_info *info)
	if (info->pc_offset < 0) /* leaf */
	if (info->pc_offset < 0) /* leaf */
		return 1;
		return 1;
	/* prologue seems boggus... */
	/* prologue seems boggus... */
err:
	return -1;
	return -1;
}
}