Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3578884pxb; Mon, 24 Jan 2022 12:41:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiC3dkKZBMCl6hOVSzdqjlhl3AgPWx64HZ/qgk1+t7fXde3vYOLQdj5yqCiZ7D3T3DiwMg X-Received: by 2002:a17:902:e547:b0:14b:47b3:c093 with SMTP id n7-20020a170902e54700b0014b47b3c093mr7414211plf.118.1643056872851; Mon, 24 Jan 2022 12:41:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056872; cv=none; d=google.com; s=arc-20160816; b=TwG4Kuwet29JcnD4UjGZt+3P2qSMecn4u1ihWOuFkKTA8nFMS41yirpU43EIivU36O VgVxIbhGhbRDggTvJLftvQlqmBsR7HWYcZ5ymV1q2L38vdN/fDXu9uCts6T7CxeHXZZn SMCpMVxZw41ZLnWy5QjtiN9NFsOAuh0oOb+DXsLIsLxicYjGbTdQUuREdThArfMud6kR eG4ZhJQcehfm6zJ27kUuVpDQ8nV6jQDEYDXNiIZVlSIEyvcI3w2xqqeAUzCGWOiBDmu3 Rnrgu7+otlfiA35elsLnKqAygfxKZYrK+AVTpmvMauleEaoyCOBAevJs414G28KRbGmO M80g== 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=PqINMdP/4Y7M6CXaYoYqvTdXtAA6JeAJFfg6Yaz3axM=; b=T7jGkxCsRmKy6mdr37len9VLKpTITdsAdOiMhx/vJuD0hsn0QanK1WFcuIDOwNYOv9 lazTe/iCRUAFOmZxQL3b1LW0zLSmSdhIjgDJRRtWMF5pdAumTO4wRArAyEXWo5+3LyVX Be8F7r/Ui7eW2e8Dr10KtBkyXD5juZZcCcHH2QiQn7QGEG/qMINaKfqFxWzYpbGlypxv eUStUqHASobs8MGAdJCcZEnPpQPFLUvuyjk1pJlK9zbAiJ70iqMP5m7vKJK7/oGMuvd1 BccjM7dbia3zCwl9coPBcK/Q3hUj8wCFdlDc0fiE3ml20y3wMosq33I1mFEO7smsZkEP s9Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mTopkVwa; 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 o24si12886683pgb.565.2022.01.24.12.40.58; Mon, 24 Jan 2022 12:41:12 -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=mTopkVwa; 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 S1345661AbiAXT4o (ORCPT + 99 others); Mon, 24 Jan 2022 14:56:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354598AbiAXTgt (ORCPT ); Mon, 24 Jan 2022 14:36:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A25F0C06137F; Mon, 24 Jan 2022 11:16:59 -0800 (PST) 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 5FD43B8121C; Mon, 24 Jan 2022 19:16:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70B88C340E5; Mon, 24 Jan 2022 19:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051817; bh=roOoVmBLp8DGLovcxZsX04NbD9zAfwHu/iuBHS6vXH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mTopkVwaT+3kDZSKLWF10HJuMaaKYn029nvUP4UgMfaFS9Yxn4oFpIOmVrdxp9aSO AF/6BAjrcg9TsS+rRd5x6HiFW8+7Pnt5p5tRPvkO8NUD5uRfB5tMVGtDzMFggN62Xo t+3uBaJl6KgAMhYbS+4HVVrmHu1o+0Z4NOod4nms= 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 4.19 096/239] pcmcia: fix setting of kthread task states Date: Mon, 24 Jan 2022 19:42:14 +0100 Message-Id: <20220124183946.158719236@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 8c8caec3a72cc..182e5ef4ab83d 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -669,18 +669,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