Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9414289pxu; Mon, 28 Dec 2020 15:43:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFwzL4G4MWwlW1hHTdl1y532v4uONTDpcFqPc3VTEJu3KONGkBOTxO3nGdGbpvjmrmL3Iy X-Received: by 2002:a17:906:4e52:: with SMTP id g18mr44830189ejw.385.1609199006688; Mon, 28 Dec 2020 15:43:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609199006; cv=none; d=google.com; s=arc-20160816; b=qeVmC6jmtLXrohEdRNUd4GwEHcBmjz2G37cRyS3jME+eT4qURUAMunDSNhtS3ohh0+ 8LOtdA40aKIgU9G7NyDoUM8qwO7Lk26Xnow7pRBTN0/QVicYvMVsuEK/xXABiUD1zJ37 Qm8FM/AXW3YOAW85JGArd9yHKlRso2fMBn030tNW7n6wdLTWkuhSF3qg53d5RycUoXCJ CW//mlw+K6DGa/FCm637XOj3VWSOUKJ0DuB8KH2CCju3bUg61IvQfz+lNVlYkMkbGTdL ZlTgDXJCVvrZ2fn/U1OFlftXR3p4S9362TBp8rc4LiJpEJz41dKvvCnXjGW8cQV9/QWl VhHg== 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=eLzAccta8c1HQHE59WFWlAadpMP3/mi+kx92DH1KC0E=; b=CTUyqgxxt49mqe4AaSjFD6sn6DGJcf41zXxPD2kBOJKtFR2Y5k4it1mlNDoeX1+ouB 8lEJ8tO0TOR46UZBy0NDFHASzVhxfKiyl7VtNZHq56rutnFfhC6IUhZ4I4gY4CFpvua4 HDm9U3poQ2iV4bEWWrH2CN1UXFjsD27eSGygsvKSI9U31Eq+Rh311CUg2VSk3jd7jzlz QE3UQIVVH7WnuAyQlv37QUPNfJFa/4gQsTrAjR0HPomiwYzmcZujvV9Z+Zf40LOnAwLE DqOh7R7hA7Ji4NZkRprhOVinFlwH2XGNhrIqvyRQbPOB793y3dLp9w156XMtr4qINUCi e5kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SFcHHnFS; 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 n8si20654334edy.54.2020.12.28.15.43.05; Mon, 28 Dec 2020 15:43:26 -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=SFcHHnFS; 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 S2504779AbgL1Ocn (ORCPT + 99 others); Mon, 28 Dec 2020 09:32:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:39864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392101AbgL1Obw (ORCPT ); Mon, 28 Dec 2020 09:31:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4620920791; Mon, 28 Dec 2020 14:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165896; bh=WmPOZiA28eMxsh5USZaoHVnbE4Q8/E4DuTNXX/FnMBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFcHHnFSqI5+OEse81ieiDahq6XGjyuqqfkGGEYdR08w9RfgFPHsDkg0xSYSD1Bos GliyGoyqyQPijwa+p+YbtuWnZcPcntwKX+GPtMizIYEOGydsng1PGal2MvvDAgxWfK qJJQYNgtBjOt6d7VjkLW/J3WH/viqVCJzMgBlvKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , Takashi Iwai , Saravana Kannan Subject: [PATCH 5.10 694/717] driver: core: Fix list corruption after device_del() Date: Mon, 28 Dec 2020 13:51:32 +0100 Message-Id: <20201228125054.232036599@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Takashi Iwai commit 66482f640755b31cb94371ff6cef17400cda6db5 upstream. The device_links_purge() function (called from device_del()) tries to remove the links.needs_suppliers list entry, but it's using list_del(), hence it doesn't initialize after the removal. This is OK for normal cases where device_del() is called via device_destroy(). However, it's not guaranteed that the device object will be really deleted soon after device_del(). In a minor case like HD-audio codec reconfiguration that re-initializes the device after device_del(), it may lead to a crash by the corrupted list entry. As a simple fix, replace list_del() with list_del_init() in order to make the list intact after the device_del() call. Fixes: e2ae9bcc4aaa ("driver core: Add support for linking devices during device addition") Cc: Reviewed-by: Rafael J. Wysocki Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20201208190326.27531-1-tiwai@suse.de Cc: Saravana Kannan Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1386,7 +1386,7 @@ static void device_links_purge(struct de return; mutex_lock(&wfs_lock); - list_del(&dev->links.needs_suppliers); + list_del_init(&dev->links.needs_suppliers); mutex_unlock(&wfs_lock); /*