Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

memstick: Add timeout to prevent indefinite waiting

Add timeout handling to wait_for_completion calls in memstick_set_rw_addr()
and memstick_alloc_card() to prevent indefinite blocking in case of
hardware or communication failures.

Signed-off-by: Jiayi Li <lijiayi@kylinos.cn>
Link: https://lore.kernel.org/r/20250804024825.1565078-1-lijiayi@kylinos.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Jiayi Li and committed by
Ulf Hansson
b65e630a 709fe7aa

+6 -2
+6 -2
drivers/memstick/core/memstick.c
··· 370 370 { 371 371 card->next_request = h_memstick_set_rw_addr; 372 372 memstick_new_req(card->host); 373 - wait_for_completion(&card->mrq_complete); 373 + if (!wait_for_completion_timeout(&card->mrq_complete, 374 + msecs_to_jiffies(500))) 375 + card->current_mrq.error = -ETIMEDOUT; 374 376 375 377 return card->current_mrq.error; 376 378 } ··· 406 404 407 405 card->next_request = h_memstick_read_dev_id; 408 406 memstick_new_req(host); 409 - wait_for_completion(&card->mrq_complete); 407 + if (!wait_for_completion_timeout(&card->mrq_complete, 408 + msecs_to_jiffies(500))) 409 + card->current_mrq.error = -ETIMEDOUT; 410 410 411 411 if (card->current_mrq.error) 412 412 goto err_out;