Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1270244pxa; Thu, 20 Aug 2020 07:12:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxufm5CSotOq6mWORpyuvFH0ySkOQU5IqSamHgwGJkb/i4/tkkO1uqK0dCtu0kb+bJC1Q43 X-Received: by 2002:a17:907:11dd:: with SMTP id va29mr3574553ejb.470.1597932720321; Thu, 20 Aug 2020 07:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597932720; cv=none; d=google.com; s=arc-20160816; b=R8x/Rngtqvnz2BKNy3JDxZY+qyICdouaLyMrnMUoyWXasUTJ6Sg73HYSDBNags+AKy mBDb7YW0f2fh1zzAGhc/17oxIS7D5dS/XaZ6cdHoERXUB/loEN9LQUTvp5mlekpeh3Ib eEnxplBTrCpSpyxkoK07HOrpKomWd8D9piohbyjKP0ywztiMmBwIJ1ZEub5NbFOC8Bi3 O5QhfovNLijdrcdxrx7xLFoL1k0l6JMelB/ELYEey8s+zznlb+0u1/52P8TjwtDcU0z1 Qhtdf+8vc7X8lQwqxdlrJxF5Q0QIbIldjCchCY18U7PLpTAp8F3ykgiGgsH3h2fafPS2 geLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cgVEgJzew0CAdr36jr393+ls6HSnEwA9X1TClc209WE=; b=ffQYyhXsYjLilo4SDeNGKQ48Wzyl1DoIznlf7L8RkeO35Kqb4Zo8YXfZRxxZRWE6/d DiZ9m3Mpl4f62od0eg0EKTFGkdt+qsMfqRhgh+HN6i+DqSCvozk2KFXHcdx6Jk+j+y1F NRlz+Ef5D1AYZzKeLqJraIDSkmFazGwczBZlgEIKxv6yNLEjZ0UY7h7flQ222lYymFif W4bKrKXsC9cfbTuqjhDMuzOmucQieq1cQTdtkwg8+jaMD6MrWbXKotmy987X/qc7O3Qi bM63pZdpOPRzyvuMm8dHTsGmLAfytToAvJwiwNOY8QZLBPh5QHwYM7DuO/PcNfMBVC6l mxww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GU47jW7z; 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=fail (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 y3si1774728ede.295.2020.08.20.07.11.35; Thu, 20 Aug 2020 07:12:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=GU47jW7z; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731030AbgHTNzP (ORCPT + 99 others); Thu, 20 Aug 2020 09:55:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:35924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727921AbgHTJ0p (ORCPT ); Thu, 20 Aug 2020 05:26:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04C8B22CF7; Thu, 20 Aug 2020 09:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915604; bh=VS46scwFVsaKDkyhE6NIl1+c/wDesdKoeConpx7g6ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GU47jW7zuMGxGWo81YQLZo4GKviW4DmZfyU9F45d5pqaNXPpkwJT54PLlqgPbmtEi EKRkWXphUgQIbL0SwVVvZm2bOwsNwSsl/89tOwJPQ+HcwWTciHiQDDVPNXyIplAu2Y 2xP9GfO/X1dcGRxWiCfjI86uUaMy/+Wp/e47yTnY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Alexander Duyck Subject: [PATCH 5.8 072/232] driver core: Avoid binding drivers to dead devices Date: Thu, 20 Aug 2020 11:18:43 +0200 Message-Id: <20200820091616.290353265@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 654888327e9f655a9d55ad477a9583e90e8c9b5c upstream. Commit 3451a495ef24 ("driver core: Establish order of operations for device_add and device_del via bitflag") sought to prevent asynchronous driver binding to a device which is being removed. It added a per-device "dead" flag which is checked in the following code paths: * asynchronous binding in __driver_attach_async_helper() * synchronous binding in device_driver_attach() * asynchronous binding in __device_attach_async_helper() It did *not* check the flag upon: * synchronous binding in __device_attach() However __device_attach() may also be called asynchronously from: deferred_probe_work_func() bus_probe_device() device_initial_probe() __device_attach() So if the commit's intention was to check the "dead" flag in all asynchronous code paths, then a check is also necessary in __device_attach(). Add the missing check. Fixes: 3451a495ef24 ("driver core: Establish order of operations for device_add and device_del via bitflag") Signed-off-by: Lukas Wunner Cc: stable@vger.kernel.org # v5.1+ Cc: Alexander Duyck Link: https://lore.kernel.org/r/de88a23a6fe0ef70f7cfd13c8aea9ab51b4edab6.1594214103.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -844,7 +844,9 @@ static int __device_attach(struct device int ret = 0; device_lock(dev); - if (dev->driver) { + if (dev->p->dead) { + goto out_unlock; + } else if (dev->driver) { if (device_is_bound(dev)) { ret = 1; goto out_unlock;