summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWentao Liang <vulab@iscas.ac.cn>2025-01-20 21:10:06 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-09-09 19:02:36 +0200
commit369bf6e241506583f4ee7593c53b92e5a9f271b4 (patch)
treee38f0dfcea60c7ac4dfed6ef7824a227f5b6f004
parentafc07186508fd72ec3878500ae4dba55fe29e739 (diff)
pcmcia: Add error handling for add_interval() in do_validate_mem()
[ Upstream commit 4a81f78caa53e0633cf311ca1526377d9bff7479 ] 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: 7b4884ca8853 ("pcmcia: validate late-added resources") Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index bf9d070a4496..da494fe451ba 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -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);
}