Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6249640iob; Tue, 10 May 2022 13:58:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6HAECCROqxkZe3KjLIvMVmJDDwt4SBOeZTZ3gc1LiTQD4tbbpTsgfUc44yVWC6P7LT5fR X-Received: by 2002:a05:6402:42d4:b0:416:5cac:a9a0 with SMTP id i20-20020a05640242d400b004165caca9a0mr25564647edc.86.1652216335278; Tue, 10 May 2022 13:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652216335; cv=none; d=google.com; s=arc-20160816; b=Eewv/s1KLiTzsFC1Ycx1MQFiV/uwLwH7UTSPIHEY4jQ1ev7ao53ESC63ujLoWvK3KM U6jWV1DxpupjNYxwQirhXDIpMgDzgfDz2IPzPDTfwuQTdtWFhlSCepoxB7D5w34kmAdK 0bI1tnhnMeeQOk8f5LVvgfMk4yIGPPGBUgKtICIYS1bIrln8bFbtNpvt9jzBa48vr8W1 w0MiNJiDu7cceL8Mfv8AJnzkotmAvaHwvQXfA7uYeZkXq861JbJUQzA6KGayAvC8DEOw OEU3qkjMePkE6IVcBIBkkq90JE/MRjletgRGS9X31XNRw5wT7bLM2peO5yzYmODRCGVL pb6Q== 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=MLqmRxT0wTkhEOP7Moe4lZX9asoInEueiiz+Vu0OeaU=; b=ZjNFbjtSLw3V1cw89r86GYlhM+xW2FTqwYFctxW+t9NWxu8w4G/spFf1flRrkLm6CG BvLbnYQGDsxSMM1Q12G2xe0T2LI0y0a16Eg0cZHPqwDKqsi7y2DkDEKHJKgyANfWkkv8 ERmW8O0S14DGgzDuzTYfcO9R/chHSBUM48lwo9aEmIrwC8WIN8qtJyyagRdOi8CP0pwd S6316uwlCz8iBMm4yOWw/iwGnhakAy23Q3QymN27uLBHd00vwQy2kB9wcYE7c9W2gOO5 TFz5uYyL/KDSQktzXDY0h1DTbj2tACRvbFLA71gpdSCHo12sv6UaEf8xc23v+hVA/tGH PjWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QG9OWtC4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn31-20020a1709070d1f00b006f428802b05si452477ejc.220.2022.05.10.13.58.31; Tue, 10 May 2022 13:58:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QG9OWtC4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244064AbiEJNcd (ORCPT + 99 others); Tue, 10 May 2022 09:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240821AbiEJNXc (ORCPT ); Tue, 10 May 2022 09:23:32 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF6FC1C15C2; Tue, 10 May 2022 06:17:14 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id 15294CE1EE5; Tue, 10 May 2022 13:17:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B385C385C9; Tue, 10 May 2022 13:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652188623; bh=beJbuLc5DeQE1QzkilhzXFk8FrAnqajPtypHf3GrpYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QG9OWtC4PDtqTE/8hOKUhRFSSyr814Camv9iA2kL2vbRU70ivOjRKLUCaXM5NvTxb Y70QNvRgBCLi9pPULSlXi03G/Fy/ejIVDB42bTHPDnHtC8jQqgsJosLpVrSKMN3PJZ hDRqFhnmL+ZhznA1XmY5Ukq9slV3FD/pjmG8WPxE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Armin Wolf , Guenter Roeck Subject: [PATCH 4.14 67/78] hwmon: (adt7470) Fix warning on module removal Date: Tue, 10 May 2022 15:07:53 +0200 Message-Id: <20220510130734.514033328@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130732.522479698@linuxfoundation.org> References: <20220510130732.522479698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Armin Wolf commit 7b2666ce445c700b8dcee994da44ddcf050a0842 upstream. When removing the adt7470 module, a warning might be printed: do not call blocking ops when !TASK_RUNNING; state=1 set at [] adt7470_update_thread+0x7b/0x130 [adt7470] This happens because adt7470_update_thread() can leave the kthread in TASK_INTERRUPTIBLE state when the kthread is being stopped before the call of set_current_state(). Since kthread_exit() might sleep in exit_signals(), the warning is printed. Fix that by using schedule_timeout_interruptible() and removing the call of set_current_state(). This causes TASK_INTERRUPTIBLE to be set after kthread_should_stop() which might cause the kthread to exit. Reported-by: Zheyu Ma Fixes: 93cacfd41f82 (hwmon: (adt7470) Allow faster removal) Signed-off-by: Armin Wolf Tested-by: Zheyu Ma Link: https://lore.kernel.org/r/20220407101312.13331-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/adt7470.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -33,6 +33,7 @@ #include #include #include +#include /* Addresses to scan */ static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END }; @@ -273,11 +274,10 @@ static int adt7470_update_thread(void *p adt7470_read_temperatures(client, data); mutex_unlock(&data->lock); - set_current_state(TASK_INTERRUPTIBLE); if (kthread_should_stop()) break; - schedule_timeout(msecs_to_jiffies(data->auto_update_interval)); + schedule_timeout_interruptible(msecs_to_jiffies(data->auto_update_interval)); } return 0;