Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3603050pxb; Mon, 24 Jan 2022 13:17:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7V4gIa9Wq3OEZiLW/nAI/EDz15FCIJhtlDhEVggyV0zi9oTebMdlVGh+fBhU4WZ0gycX5 X-Received: by 2002:a63:a846:: with SMTP id i6mr13240752pgp.317.1643059024982; Mon, 24 Jan 2022 13:17:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059024; cv=none; d=google.com; s=arc-20160816; b=JpC5KkINW+Bnn+ceFy0nPKEXVWOu9zAH8alc8VvE9ESVXPTqG02EaRafKsb0bVB4w6 AVwiwFv03MPsTooXwXcbQAgpHhjYzfs3gTOw4daoj2/uwzIvrVV4jePSqvDMolkxoF6b eVD0OaK5LIQXa42CEKSUhsnkEsmi+nUnfUGSZ6ahyBhKzh2uu3GWpBQECFKdotJXnG5S PGKgP/J0hK/974eGCPqPUHKe2Gyh+O7hCfKgK4kPTTnGhuGuWFP7nBnytZSFwYuHzFza LxvS2fth/C6CLMGNHXf3eDS3Ad41RDorlYgdphvl+QwUPSnOOGr9TFEC7uZu1Zfq+MOF QPuA== 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=qWs+r7eSMeUSAWROhxYNXBGnra/rghOuUd78YkqVDdvffLRNMkuegntiTv5sSAmpKV xal4W9TEDPVwk4lpOkJovh4PA0BGJoZBZckgLRVOubELzNgwoeEsVnpPXG9fJQk2geFC FoP3zIgDM13yGh1QFtlayoaGBrx4PuF37UGqhnkJqJf2/X/U24T98bbAbL3xE9mCxFSj B9Cqimz5GEGODxVx8gKattdK7E72ksjKrrOGwnC4j4cGcOnnfp/9VPZwHsw9meIRbcc2 S0QbD/XdJdhR01lxJTuU0GtOIVFIjqHreL3Ndlmj9GilyEn1bE7MjwpwsYpL0jiYBOtt lM6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A0WFYp3s; 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 nv2si468695pjb.20.2022.01.24.13.16.52; Mon, 24 Jan 2022 13:17:04 -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=A0WFYp3s; 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 S1358486AbiAXUv4 (ORCPT + 99 others); Mon, 24 Jan 2022 15:51:56 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:35322 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384067AbiAXU2x (ORCPT ); Mon, 24 Jan 2022 15:28:53 -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 ams.source.kernel.org (Postfix) with ESMTPS id 33843B81239; Mon, 24 Jan 2022 20:28:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4828CC340E5; Mon, 24 Jan 2022 20:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056128; bh=g6pSpn2i0X05d9/e/pvWbJQ995pdOEPCyDaWB64n2Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A0WFYp3stJ8v89n5nFk7/EgP4CM95DmOi7kw96WsxY5XSWNEZv3ENTZ4AXWnBL22v k4dDuCfmRsiUYtbAqenyJOYjN1kuSzWK5JlAZMO0n+O2Xq/0qWtVH4MHgaM7LDrNzD p7rm4kGjJsFlZEJB8ecCpNeiSzeyz9AmhB6MqPYs= 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.15 363/846] pcmcia: fix setting of kthread task states Date: Mon, 24 Jan 2022 19:38:00 +0100 Message-Id: <20220124184113.452642141@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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