Commit 4a81f78c authored by Wentao Liang's avatar Wentao Liang Committed by Dominik Brodowski
Browse files

pcmcia: Add error handling for add_interval() in do_validate_mem()



In the do_validate_mem(), the call to add_interval() does not
handle errors. If kmalloc() fails in add_interval(), it could
result in a null pointer being inserted into the linked list,
leading to illegal memory access when sub_interval() is called
next.

This patch adds an error handling for the add_interval(). If
add_interval() returns an error, the function will return early
with the error code.

Fixes: 7b4884ca ("pcmcia: validate late-added resources")
Signed-off-by: default avatarWentao Liang <vulab@iscas.ac.cn>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 750da502
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -375,7 +375,9 @@ static int do_validate_mem(struct pcmcia_socket *s,

	if (validate && !s->fake_cis) {
		/* move it to the validated data set */
		add_interval(&s_data->mem_db_valid, base, size);
		ret = add_interval(&s_data->mem_db_valid, base, size);
		if (ret)
			return ret;
		sub_interval(&s_data->mem_db, base, size);
	}