Skip to content

Commit 4a81f78

Browse files
ISCAS-VulabDominik Brodowski
authored andcommitted
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: 7b4884c ("pcmcia: validate late-added resources") Signed-off-by: Wentao Liang <[email protected]> Signed-off-by: Dominik Brodowski <[email protected]>
1 parent 750da50 commit 4a81f78

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/pcmcia/rsrc_nonstatic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,9 @@ static int do_validate_mem(struct pcmcia_socket *s,
375375

376376
if (validate && !s->fake_cis) {
377377
/* move it to the validated data set */
378-
add_interval(&s_data->mem_db_valid, base, size);
378+
ret = add_interval(&s_data->mem_db_valid, base, size);
379+
if (ret)
380+
return ret;
379381
sub_interval(&s_data->mem_db, base, size);
380382
}
381383

0 commit comments

Comments
 (0)