Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2380369pxj; Mon, 10 May 2021 01:14:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPM9hwbSNXY18AtS3YQoehw4aqdgAaCvTqRpQvfT578loX+L5Plw4Y2/xpmD15CI1JHn33 X-Received: by 2002:a17:906:9381:: with SMTP id l1mr24098968ejx.45.1620634491579; Mon, 10 May 2021 01:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620634491; cv=none; d=google.com; s=arc-20160816; b=rGWp3EGIlTlcrasFkhXoWZnEsyDEUTh02p5wUEakWiszDf856dHVtZUpMLNybwIkH7 jpAC2PXnCY4g0fQk6GAO2H6nWRLQ7pRWuZsGnAbbwF83l4TrQd+PfJ46uYdtyyfSrsJb 4XEc3glxlnPabeena07j5uRKuL4HmIoEyOYejdRzBc6h7vY3FAcEc0P2X+t982YWj5RQ aTMQ6dGeMR5F/JWmcApf+xqDvHr/Mh8aGSipeNq+xVcNPIIfNvf97Msgcwy+bbm+Ud5Y ta4w58OmbJd1KWfhtxa91wPvGOaAxowRH6AGtM+2Ovp7Y2VTjA+ZUI3p8F3owu0XebY4 NIQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=nnlBuFNxD2pkJZkScxb0omPoXoqwYg+oxLnNQiEHPMg=; b=AYECG3xg2nZ51hiSBH1RKJvufrJrpvI2dIiJYdI3BxnhzGUk2pqsUW2Xs33A/KxUZi MEnv/9TwzoE1kqRrupov6MZfYJuCffUKe7bRD4ayaFkOAza8qVJmhlFEN8jrahQUC3Ta KkRjKrO7jk/gVbIVnAylDmd3JvpQZ7tbhN4ksSNX1pBcY9ZEwGmBafKlMHm+figODk6W LSxu8W6eqVQBsm3hZtr58DGGf7VmPW1g4tU0Tin41tybYl6rdLLjSBXBZ/uBwad5RVSn 5PjvtR4RK8eJb3D4Jyi++81ov+Bw3w7EUComuInbZ1I//7kGFfVCPr9oe/gbssrCOkPh 9WTg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si12553471edx.492.2021.05.10.01.14.28; Mon, 10 May 2021 01:14:51 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230197AbhEJINd (ORCPT + 99 others); Mon, 10 May 2021 04:13:33 -0400 Received: from mail-lj1-f174.google.com ([209.85.208.174]:37778 "EHLO mail-lj1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230045AbhEJINc (ORCPT ); Mon, 10 May 2021 04:13:32 -0400 Received: by mail-lj1-f174.google.com with SMTP id b7so19704517ljr.4 for ; Mon, 10 May 2021 01:12:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nnlBuFNxD2pkJZkScxb0omPoXoqwYg+oxLnNQiEHPMg=; b=tCmA22EQngZtyr8UBfexsCmQijGxjSN4zOXq4ycu0e7a3G8uzFxak3VeZSko0aHGCQ gYpZ928m1NEPy3g76We+sQsQQBJRjlKPx7ENgNzX7OnAQjUBNJQdl8YoGujUROSCtq68 xW/wBqGxL0CRLv2PA3zquHPJJebgkopMP+2bI6WqwlOpqeNRB+aYRht9gjpgGkoHO8Xr NS/B5NplSTl5pzV0vSVox+dCVEmqCG6GWKCnyNojd5QklILA+KxHr+EE9zzWwNyUA22+ EzIZqjKkFuRwkNjobduZ6g7z01incYrfVTdv+wmbBXi07YKhXXtTpLorph4NI9WfEs8+ jrhw== X-Gm-Message-State: AOAM5326RAqMqkRMTeKq3URFNcjrSZ7k/om+Du7JkDXGGNVmlrOoM73q ippF3StJZ9ch9MPYyfMEztEwSlNbWa4vrg== X-Received: by 2002:a2e:b605:: with SMTP id r5mr18635695ljn.483.1620634346224; Mon, 10 May 2021 01:12:26 -0700 (PDT) Received: from localhost.localdomain (dc7vkhyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16e2:8300::2]) by smtp.gmail.com with ESMTPSA id m13sm3136915ljb.10.2021.05.10.01.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 01:12:25 -0700 (PDT) Date: Mon, 10 May 2021 11:12:19 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , MyungJoo Ham , Hans de Goede , Matti Vaittinen , Marek Szyprowski , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] extcon: extcon-max77693.c: Fix potential work-queue cancellation race Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The extcon IRQ schedules a work item. IRQ is requested using devm while WQ is cancelld at remove(). This mixing of devm and manual unwinding has potential case where the WQ has been emptied (.remove() was ran) but devm unwinding of IRQ was not yet done. It may be possible the IRQ is triggered at this point scheduling new work item to the already flushed queue. According to the input documentation the input device allocated by devm_input_allocate_device() does not need to be explicitly unregistered. Use the new devm_work_autocancel() and remove the remove() to simplify the code. Signed-off-by: Matti Vaittinen --- Please note that the change is compile-tested only. All proper testing is highly appreciated. --- drivers/extcon/extcon-max77693.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77= 693.c index 92af97e00828..1f1d9ab0c5c7 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -5,6 +5,7 @@ // Copyright (C) 2012 Samsung Electrnoics // Chanwoo Choi =20 +#include #include #include #include @@ -1127,7 +1128,10 @@ static int max77693_muic_probe(struct platform_devic= e *pdev) platform_set_drvdata(pdev, info); mutex_init(&info->mutex); =20 - INIT_WORK(&info->irq_work, max77693_muic_irq_work); + ret =3D devm_work_autocancel(&pdev->dev, &info->irq_work, + max77693_muic_irq_work); + if (ret) + return ret; =20 /* Support irq domain for MAX77693 MUIC device */ for (i =3D 0; i < ARRAY_SIZE(muic_irqs); i++) { @@ -1254,22 +1258,11 @@ static int max77693_muic_probe(struct platform_devi= ce *pdev) return ret; } =20 -static int max77693_muic_remove(struct platform_device *pdev) -{ - struct max77693_muic_info *info =3D platform_get_drvdata(pdev); - - cancel_work_sync(&info->irq_work); - input_unregister_device(info->dock); - - return 0; -} - static struct platform_driver max77693_muic_driver =3D { .driver =3D { .name =3D DEV_NAME, }, .probe =3D max77693_muic_probe, - .remove =3D max77693_muic_remove, }; =20 module_platform_driver(max77693_muic_driver); --=20 2.25.4 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --J/dobhs11T7y2rNN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmCY6uMACgkQeFA3/03a ocXEYAf/SFALXGyMLHS9gnpEVjC2bHDDM2tS0VhZOLPD7Mv8tnenaKJUoYLni14k 36bjBY+MCI4CINem6BwaHDG+phDdosu5OvXXkfWVSdKt533QdWtbXBMC2xR3jF/S GmUhIsGfC0vbujl7VVwW2hJvp3tw4Z46Kl/RQlyBLHX1JRHDDDVomhbxB3i1+S84 qtuiG9NPebq1Zm2LsdFdcBWJkdRuLQ3t+/4xVMNNrHQKON9gf15jaw5moNo2WRDQ lW1iG1IsHaKxxOj1qbhSPLe99cM2djiUvmV9pBVg+46fLUB/ovd3ZZyhCF+Ux+D6 pdhK9uecg5JhCPV9VUsJhG/HfX3iRw== =+K/V -----END PGP SIGNATURE----- --J/dobhs11T7y2rNN--