From nobody Tue Apr 28 01:14:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16880C433EF for ; Wed, 8 Jun 2022 09:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235327AbiFHJ7D (ORCPT ); Wed, 8 Jun 2022 05:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235754AbiFHJ6P (ORCPT ); Wed, 8 Jun 2022 05:58:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60911FA5F for ; Wed, 8 Jun 2022 02:30:46 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LJ2444JPgzjY8J; Wed, 8 Jun 2022 17:29:24 +0800 (CST) Received: from localhost.localdomain (10.175.127.227) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 8 Jun 2022 17:30:44 +0800 From: Zhang Wensheng To: , CC: , , Subject: [PATCH -next] driver core: fix deadlock in __driver_attach Date: Wed, 8 Jun 2022 17:43:55 +0800 Message-ID: <20220608094355.3298420-1-zhangwensheng5@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In __driver_attach function, There are also potential AA deadlock problem, like the commit b232b02bf3c2 ("driver core: fix deadlock in __device_attach"). Fixes: ef0ff68351be ("driver core: Probe devices asynchronously instead of = the driver") Signed-off-by: Zhang Wensheng --- drivers/base/dd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 11b0fb6414d3..b766968a873c 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1115,6 +1115,7 @@ static void __driver_attach_async_helper(void *_dev, = async_cookie_t cookie) static int __driver_attach(struct device *dev, void *data) { struct device_driver *drv =3D data; + bool async =3D false; int ret; =20 /* @@ -1153,9 +1154,11 @@ static int __driver_attach(struct device *dev, void = *data) if (!dev->driver && !dev->p->async_driver) { get_device(dev); dev->p->async_driver =3D drv; - async_schedule_dev(__driver_attach_async_helper, dev); + async =3D true; } device_unlock(dev); + if (async) + async_schedule_dev(__driver_attach_async_helper, dev); return 0; } =20 --=20 2.31.1