From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 159B3314B76; Wed, 3 Dec 2025 15:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764777531; cv=none; b=GTywd/7GTBKMi8C1CN4eYTTzbDrVdGQbkT+iK8A3r6LW0e6k6uQ2J63Nl6nTdeNriZunUNVovuqv2AIBrKp3DHTWBUKSZ3Q4AdJRfTCxjj1MC9cb+b9C08bRkRgb9+x/Jctm2WXpO1U0MnGhax+ndpfmOJBx9RdGlTA2SkrTKa4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764777531; c=relaxed/simple; bh=ATvA/oZ0E3WDUs8LcyBPdWWNrFNqJMtgpMs23jU4E4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zq95E+7sU+bksBuAb8fXsxMeyev8/b1cxqoCC6MBMy3ZI+1M3wZ7/mYQwL7O6RvW0kY3HvklkFVtJrNuBmM7i5ChTAlMih4mxxv4VdBIlgJmGEeCllmBwXlW4yHvQw4GaCiOacI5KTjWO4q7dMDnqM/q7HtGMUXsH2IJwueDzaY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Rx9ZmUmu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Rx9ZmUmu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1D0FC4CEF5; Wed, 3 Dec 2025 15:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764777530; bh=ATvA/oZ0E3WDUs8LcyBPdWWNrFNqJMtgpMs23jU4E4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rx9ZmUmu7VSvewmE4T/bOIFUowzC6ffCakBYAPkJpddtuiaVgQxFYJDga/WCP/SYE 5BhV3zWrZKG9eeUcA5wTl/B9c8FrmMtmuTKg110goeCEpRna8DVNpoUO6WYC280vsX Rppm5qNVg0+VNK1J2YKhQjzhmcOfVZtr0l4PzB24= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiayi Li , Ulf Hansson , Sasha Levin Subject: [PATCH 5.15 060/392] memstick: Add timeout to prevent indefinite waiting Date: Wed, 3 Dec 2025 16:23:30 +0100 Message-ID: <20251203152416.321029562@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152414.082328008@linuxfoundation.org> References: <20251203152414.082328008@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiayi Li [ Upstream commit b65e630a55a490a0269ab1e4a282af975848064c ] 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 Link: https://lore.kernel.org/r/20250804024825.1565078-1-lijiayi@kylinos.cn Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/memstick/core/memstick.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index 9a2acf5c40143..fc9e6db3bb72b 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c @@ -367,7 +367,9 @@ int memstick_set_rw_addr(struct memstick_dev *card) { card->next_request = h_memstick_set_rw_addr; memstick_new_req(card->host); - wait_for_completion(&card->mrq_complete); + if (!wait_for_completion_timeout(&card->mrq_complete, + msecs_to_jiffies(500))) + card->current_mrq.error = -ETIMEDOUT; return card->current_mrq.error; } @@ -401,7 +403,9 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host) card->next_request = h_memstick_read_dev_id; memstick_new_req(host); - wait_for_completion(&card->mrq_complete); + if (!wait_for_completion_timeout(&card->mrq_complete, + msecs_to_jiffies(500))) + card->current_mrq.error = -ETIMEDOUT; if (card->current_mrq.error) goto err_out; -- 2.51.0