Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558429pxb; Mon, 24 Jan 2022 12:11:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyViZ3hWGD68JEQ4OJVgJ5bnFWQt+jA2KdD1gwp4/lAymCTStDHMFNPw/nN2XzsJd6UTpaJ X-Received: by 2002:aa7:9399:0:b0:4c9:6049:cb7e with SMTP id t25-20020aa79399000000b004c96049cb7emr5447650pfe.63.1643055083595; Mon, 24 Jan 2022 12:11:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055083; cv=none; d=google.com; s=arc-20160816; b=SQtA+daYCSorjm6minosKVPnuZIyebT72qTF0XHPbyF3Vk2TOY2bHw14aDk40Tiuxm nepmBWMz3+COB5ziF9vVYPjDUvkNO1WGyw9l1lT6s9yqT0ae3HL7XM0KzfN5s07yE++l 5rUbvTyMs2Hb0wFF4qiuRPa21QKK1yhH6ZssXcrlSLZiKk3sKITacG6YHq9o3ssP2Mz6 K7gCUn/jhBqfmYKMTMwBS4Y+s+SIByIlk9xB6vYXZgm8t3yXikY0tFzOfyuRKQlB0Ntp 10tbqCqrSsOb9bHqu4OBemeQMewy4xuc/y0wX5dF54RzGakMQn5PgsBf3Se5D3DwWdkj keXA== 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=PhVU656fHE8jNMTiPGJGvLmaYmdqHBprDf+jLqtNtTW4qDQRtheYP1OVvYG3HGEjUZ 2nPZylTElnhHZfcaPDa0mlDNM0j6CxBbp5Ill3w9KUwX2F1UcaM5U+8t/AbpJ7oClBkx e50PPULYgUFgtyOYpUJsyvccSDdJpQTBcHyM4poVVf2bCQV79qM4gqPs4pGK8fjYH1yj fYxuYh7ZbsnVWLDiuS/3MNMswVRCdjb8r8DsbomDYGjrNJ/syz9q2itBmgxd7fp/mREy 7nziePUDaLVBjonf6Ld7DmQrZJ6ShlXmaI4yImOtgmTOlv6DywUVvvspNZmwNjupbR86 h5lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="j7+DG/ko"; 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 c14si13408221plg.213.2022.01.24.12.11.11; Mon, 24 Jan 2022 12:11:23 -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="j7+DG/ko"; 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 S1347923AbiAXTOg (ORCPT + 99 others); Mon, 24 Jan 2022 14:14:36 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:33080 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345476AbiAXTFn (ORCPT ); Mon, 24 Jan 2022 14:05:43 -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 E99D9B81233; Mon, 24 Jan 2022 19:05:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BB57C340E5; Mon, 24 Jan 2022 19:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051140; bh=roOoVmBLp8DGLovcxZsX04NbD9zAfwHu/iuBHS6vXH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j7+DG/koz55KLbgpyCSMFST+aOD8CLQZ0AnGuem/w6lzTC47jfGtyjXh9NTdH4Yu7 wbcl63emITSHp/EZh9KuSBY7h9Vwk9XnY/CXm7qeOWDskD15WQYaRlOqIVINwcGcsf nHFHPVMOO1LAJXfhuY5CHxFbuPw2eiQfqXo88zPk= 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.14 066/186] pcmcia: fix setting of kthread task states Date: Mon, 24 Jan 2022 19:42:21 +0100 Message-Id: <20220124183939.242365371@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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