Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp251878ybi; Wed, 29 May 2019 20:41:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwb3AuJIQO3mKJdNv7AY5wCGie2QNASGh34yqj4aaYm2tYwLDwba4Txf5gsKfrnBN02aMIH X-Received: by 2002:a65:418d:: with SMTP id a13mr1782421pgq.332.1559187663231; Wed, 29 May 2019 20:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187663; cv=none; d=google.com; s=arc-20160816; b=ByH5Kl0YOE6nZTyfRnW8bOILVAz0Zebe+phDI1GRDUNdzoKjMI0nhly7JmBqCocszM n9IpnO0OeANk/TqlXy9kEyS6oO7iTKCWT0Iub5GySHZtxcs43eTXNc/lkZXYkNVLNCO6 mJiK0LvaznTqcSy/xkfAif2RjryQDp64Y+AiIzZkF6gQICps0RVO1IB7Z91kd3M6eIec jK4UWFGSDjIVauuwUoFQfPNyWzf8JuU08TkxEq1lBU3ARvKf48cyvxlvIVvOsrFTeH1f rjM7snK9BKHkXfYzFA1d7HHYrN5eHcriqbdnle+r68pi8cZWPdfINqme0yMYkodS67oV dEHQ== 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=dc9an3fO8xHzG55AqVgjUFSTnbvrnGzBXXatrC7U88k=; b=bhO1KNGiuOBIGeKfzuqJB70mtwrs6ay/1jSGyZF2pFDMsrOyHl2CqrJiOqmRFY3xrB QNpJiB4Y04d/ZtOswTyph/Nu6s0/0FuysPJLL9/eRk9PyYlG6V7npDqm/n+oi5g+yloR fy8rjSnrh8utEbEZlBY4CO6yRZi9m7zWNOHJZ8nm9uzKy7p/BvivB0ybgnO7b0chMNyL cBZ+9BGwARFROLZoUrFFF0u3uE92sCRD/d8AMY+mx6pBDecZJcp2KNfhHKGRU80/vxNf bkz6U9L8P53rUd833KdwsV7ordvLE+NMlcSdSGnUmevP/xBkFjvcfVXJi2X9tDetaVCN P/ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bkBah5nt; 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 q4si1921580pgc.108.2019.05.29.20.40.46; Wed, 29 May 2019 20:41:03 -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=bkBah5nt; 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 S1732696AbfE3DWI (ORCPT + 99 others); Wed, 29 May 2019 23:22:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:43158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729838AbfE3DQf (ORCPT ); Wed, 29 May 2019 23:16:35 -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 3130924590; Thu, 30 May 2019 03:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186195; bh=MjXQS3y9/+u+lZla8UU9/IM/aiALE+hEOkl2pgRuKEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bkBah5nto+xUvFqXSCf9r78g1AutI0aH59mHonuEiHwDh5NtMTT5YFCtEukfV5nj5 kDBITOJZEeFScgeDVWjoY3qFYTLP7j3gsGtF41jedTxrvDS9m7uNezlYHPMhWMXIi3 d+YEJ+CFISqJKRkSesPvCmSoxGMNWfVOqVbZhQHc= 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 4.19 068/276] ACPI / property: fix handling of data_nodes in acpi_get_next_subnode() Date: Wed, 29 May 2019 20:03:46 -0700 Message-Id: <20190530030530.373484267@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@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 693cf05b0cc44..288673cff85ea 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -975,6 +975,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