Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3644716pxb; Mon, 24 Jan 2022 14:16:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaEF/uPjBCVXns2mRTHwwmh2j6oFAFJvFezMII9roHjgHdt/CkDIeaGMQBxwRYBL5OWZOj X-Received: by 2002:a17:902:6908:b0:149:b26a:b9b5 with SMTP id j8-20020a170902690800b00149b26ab9b5mr16237813plk.169.1643062617877; Mon, 24 Jan 2022 14:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062617; cv=none; d=google.com; s=arc-20160816; b=0oLlKxZB15Mj8OIRE3hhzvkdJ/ilC8kOZlsdoYNkHXwjYTM6bGsSar8olbzijQPhpj XGhzw550ooZZUdL93LmBEud5zGQrHZRqBb3MX8m+QIDWkylT8zaKPkyvq0JFYB3XythM nFuz+q6+dmEgXfVOyiSa9w1g4qa7p83vM4S1UQvOdB+UZcTYtQN/M6gMAyM9dSvHg1+y nu3CbYx9tjWboe6n0Ka0wMt40eGdxRULclEFClEURzswNbaFvKskr9aQD79589w6NjN6 oKDte93JnIUvkkkqg1DEomuboRpVXoBjVEvup/rJHsyiE/3+0Te1jBqKgWCSpxjcYvAa RFOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ti1zlJa9Qr4Tr7rErV2jwgoVW3MTT26BqF3t72iIrvA=; b=NIDBeJzpzB6ctQlpzj8paPuwnx5X0EMkWKtvdLJv9VW+zEYX+NP9ZgwvNDfPixWKr2 F0HdzPtITzHRKIzS08g7OXP8YKesszs9okkuxT9y2tHW7rnaMYrbr+ouTA5Mh9cW4xnk NDukMi8jmCuVeTl44GUw1ld1J2twmPC9kfU03uXHIpminKMJC0z8X+OwnpEi3OkwfoFp hXlJGeMjwJUL8jn9nujr6ibFSuD+FuobGUkm8Brwjt4bRFSC5WZM/Gna0HAYUU27oCtd sbHbht+caJkf80iL4mOklwQr9FEJcxKLNhAy0P63+9qjf5BiDQldtVyK0xmDxLKgHAcA 4i1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A8TfzFup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si12490900pgi.417.2022.01.24.14.16.45; Mon, 24 Jan 2022 14:16:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A8TfzFup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1580018AbiAXWIH (ORCPT + 99 others); Mon, 24 Jan 2022 17:08:07 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:38026 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1449126AbiAXVO5 (ORCPT ); Mon, 24 Jan 2022 16:14:57 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D539061320; Mon, 24 Jan 2022 21:14:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B3B3C340E5; Mon, 24 Jan 2022 21:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058896; bh=g6pSpn2i0X05d9/e/pvWbJQ995pdOEPCyDaWB64n2Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8TfzFupAeMFv+oOIcOMkIgwCyIAZtoxIxpTUMh3Q9UZLkupdfvTAh9MqnJz/Wrvf gisa2/zIcZLd0V3XN8r/K2sfEY0ZKQy3uk/VeMVCl98xpvLLngAfpGLb4kF91mVsGP 992ygy/t9dnIQKygJgcsxWy//EFpUZ7Xz9tAFScI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , "Matthew Wilcox (Oracle)" , Dominik Brodowski , Sasha Levin Subject: [PATCH 5.16 0436/1039] pcmcia: fix setting of kthread task states Date: Mon, 24 Jan 2022 19:37:05 +0100 Message-Id: <20220124184139.955395323@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dominik Brodowski [ Upstream commit fbb3485f1f931102d8ba606f1c28123f5b48afa3 ] We need to set TASK_INTERRUPTIBLE before calling kthread_should_stop(). Otherwise, kthread_stop() might see that the pccardd thread is still in TASK_RUNNING state and fail to wake it up. Additionally, we only need to set the state back to TASK_RUNNING if kthread_should_stop() breaks the loop. Cc: Greg Kroah-Hartman Reported-by: Al Viro Reviewed-by: Matthew Wilcox (Oracle) Fixes: d3046ba809ce ("pcmcia: fix a boot time warning in pcmcia cs code") Signed-off-by: Dominik Brodowski Signed-off-by: Sasha Levin --- drivers/pcmcia/cs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index e211e2619680c..f70197154a362 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -666,18 +666,16 @@ static int pccardd(void *__skt) if (events || sysfs_events) continue; + set_current_state(TASK_INTERRUPTIBLE); if (kthread_should_stop()) break; - set_current_state(TASK_INTERRUPTIBLE); - schedule(); - /* make sure we are running */ - __set_current_state(TASK_RUNNING); - try_to_freeze(); } + /* make sure we are running before we exit */ + __set_current_state(TASK_RUNNING); /* shut down socket, if a device is still present */ if (skt->state & SOCKET_PRESENT) { -- 2.34.1