Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3547235pxb; Mon, 24 Jan 2022 11:56:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzccFcJkvUdL8BEf520IjJWjnczcKqtyFe2xMqREc/qu2Yp0bBbXAJFc45eVnDNkI9ZS0ll X-Received: by 2002:a17:90a:3f09:: with SMTP id l9mr3467247pjc.38.1643054214131; Mon, 24 Jan 2022 11:56:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054214; cv=none; d=google.com; s=arc-20160816; b=CS0gCdTfaI7Qu7GjpHJ+VhQnGgW2EvC8EJs8FzDAzhgk+k4hDa+Rg2XmcdqtnJaFnl KJAjTfldcvnhQsSMpVswGpL1dpD1cs5hULRD1j/vfrG+P2O4RkcR/E2vNkCdolqxY4Dw GNGbhdPXQZtXpaRqM7NDQN3iUBTLzWtDaByiEgnhCkDYQ0OaBgrr3g4JLnyo5Y0pftYE 0qM+vt6hhMcwOdsFCkEqiB6zXyOb4kuUtJ3ndP+6PxsCpLXdGNV+E8nVDLwftYFPAlOk uMZBCFlF7JqhV1oNSUwLhKafebpjGZRzbWLQyaXY0q1GXTaV2vRTk32D8u+M6GDGCf04 4Xmg== 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=ll6iqq8MVa8HFQw5y6K09+3/TNkdR250r6wgCOQO9kY=; b=Qxs0BQ3oKdmhn3kv2Fy91qH4M7K67LpZHCsFgOYgZ/hdlD8YnkC1amV2kXgKWUEnRg nYFlYnF5YKpTrUFID6JFs8gd1slHPankjNossBVV0/T4yFLM/xbq29m4a6aVEsUfaXSz tvJce8iq1w3CPm1Zj6YM52q8/i2EX/s08p44pAJho11lhAMfGiCDnv/ARBgWTLd2Qumw bQlU8XrmCaWe1lzycPUES2wwqTQ82umZrPJ0d/bJ24u3FhQqkOjVLDyrFL+xMVaNvmeD qtSTrQeXXHqQQpKezlLiqHslWgnmuQhd9byn55DlrXM8unj1ccSaFEvVn1ujZWHbg8Nv ttlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GCRhfs1x; 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 u31si16012516pgk.546.2022.01.24.11.56.40; Mon, 24 Jan 2022 11:56:54 -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=GCRhfs1x; 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 S1343583AbiAXSvC (ORCPT + 99 others); Mon, 24 Jan 2022 13:51:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245391AbiAXSt5 (ORCPT ); Mon, 24 Jan 2022 13:49:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0015BC06176E; Mon, 24 Jan 2022 10:49:56 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 946F3614E8; Mon, 24 Jan 2022 18:49:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7455DC340E5; Mon, 24 Jan 2022 18:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050196; bh=tnFxo+X8MhMhJfzopAdktpTd6isKsEkPQG4eerdzgBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GCRhfs1xSmzSFyX9AaCXh5hNaX+LDyG1xFA0oFB+ZnpOwVemYz07io4c49iQXwZd7 lrWGOh0OjrYRgndCVrxA1qJHapACoo3ZRzfWT/gLJnPuWixO2NzIwD+zeArI8CWbUH Bv3CjOWm8C9De4meJ/jPwnJ6Uxss8eDHUX2/DMsA= 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.4 040/114] pcmcia: fix setting of kthread task states Date: Mon, 24 Jan 2022 19:42:15 +0100 Message-Id: <20220124183928.348724102@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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 c3b615c94b4bf..a92cbc952b70b 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -665,18 +665,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