Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp309733ybi; Wed, 29 May 2019 22:00:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8VEai5CXpGiknrW/poZpC3N6eLJ5NDA2ewSNcRMu0iR+/SUhFbmJiPWGeFsx6xLOkI9Tp X-Received: by 2002:a17:902:9a83:: with SMTP id w3mr1958274plp.184.1559192423847; Wed, 29 May 2019 22:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559192423; cv=none; d=google.com; s=arc-20160816; b=yQZGJ5D4UjVQLFnUpxsiSrNGjlUYt4P/9a/YJgM5UzNs3CcdDuMbDfUjWGw8SDyuwO E9Sa6o8YJ1RkcX6jEMkbNlUv3wZa0w8YP3E2/klijFDawYZwGftjfJL7wr3W3rEwLjsx gVYyR1ymkz9PZ988Z12Fpj3UKqe3OhPAiuU2oCNMpj6CN2edbh07aWgpYYVJOX+AMVKA V/JQdrSaklfn4QkL0LaZNaSaeVxBr6fxBJEuFUYJQnSAUQ7KtsPCgFHTseyOdyuGONTx UaaflwYcAB6p6h4qH9Lg2nB//f3RIwkEdboXdGRMnYj2KcpoaIOCjTwCyoiDocjlgymC ujKg== 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=uCVkDEhAPB2/G6u4L47itCAvbTb4kw1SUJRu3KifMxk=; b=HU32yVgqKaLBqneLUja4rxRmkGeHCOLz9fw1XavfPWWhzyM2VIQK3fS6sJlghj4g9c bnO3D4OcvSj0VRQaezGfoz0suyovW3RHTb7D5V7WEj8eKx3xbzXaGvWBKj3HEc5E47z3 3miSy1PsA7OX+U1uoSASvmj9D0BObaS8Mb1FVbMtvD9z1/oGC23qChIISCOPA3itZipg 0IYE950hiXcHPnaz+7fKjF+vm7k0pls5U//AF29OdN72A9tonWV9AfW9sjygkTQ+np/+ mQJbIEbfUdDNzggXyjdbXzrT9pKIYYVbDRJtWbz/UxL9YMXhLdth2xR/oo/MKFrZU5/I eYPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g5h529iI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m11si1987269pgc.244.2019.05.29.22.00.07; Wed, 29 May 2019 22:00:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g5h529iI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389218AbfE3E4k (ORCPT + 99 others); Thu, 30 May 2019 00:56:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:46154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727907AbfE3DKC (ORCPT ); Wed, 29 May 2019 23:10:02 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 5AD5B244A9; Thu, 30 May 2019 03:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559185802; bh=2RNUE2oqUXk6JbDIODB3geUggqhl72IDzXKXwwzFYTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g5h529iIcU1wWVYSffvysPmgwgf3vswlv9zd3tRAs9y9qO8wyD2DqH3QpmyJ6H7ev iPJ125b6j4oA8QdLv3+cpf+GHKiu0as9tC/7jqWrNQHFMOdjpa5ZL/MARhaFDMU9T6 5F1tH9qWVopPqTWaN9Sl8I4Xc7ik/9rgXAxnBZfg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Andy Shevchenko , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.1 082/405] ACPI / property: fix handling of data_nodes in acpi_get_next_subnode() Date: Wed, 29 May 2019 20:01:20 -0700 Message-Id: <20190530030545.160094086@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.291644921@linuxfoundation.org> References: <20190530030540.291644921@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 [ Upstream commit 23583f7795025e3c783b680d906509366b0906ad ] When the DSDT tables expose devices with subdevices and a set of hierarchical _DSD properties, the data returned by acpi_get_next_subnode() is incorrect, with the results suggesting a bad pointer assignment. The parser works fine with device_nodes or data_nodes, but not with a combination of the two. The problem is traced to an invalid pointer used when jumping from handling device_nodes to data nodes. The existing code looks for data nodes below the last subdevice found instead of the common root. Fix by forcing the acpi_device pointer to be derived from the same fwnode for the two types of subnodes. This same problem of handling device and data nodes was already fixed in a similar way by 'commit bf4703fdd166 ("ACPI / property: fix data node parsing in acpi_get_next_subnode()")' but broken later by 'commit 34055190b19 ("ACPI / property: Add fwnode_get_next_child_node()")', so this should probably go to linux-stable all the way to 4.12 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/property.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 77abe0ec40431..bd533f68b1dec 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1031,6 +1031,14 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode, const struct acpi_data_node *data = to_acpi_data_node(fwnode); struct acpi_data_node *dn; + /* + * We can have a combination of device and data nodes, e.g. with + * hierarchical _DSD properties. Make sure the adev pointer is + * restored before going through data nodes, otherwise we will + * be looking for data_nodes below the last device found instead + * of the common fwnode shared by device_nodes and data_nodes. + */ + adev = to_acpi_device_node(fwnode); if (adev) head = &adev->data.subnodes; else if (data) -- 2.20.1