Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp10962imc; Tue, 15 Jan 2019 15:09:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7+vw8e3NQVSeXXUJ1lV+XBbkXCNTJphRg23LQKcgVpeBdNWg93bBctjfJLDuegbRwrcDF/ X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr6485915plg.222.1547593775308; Tue, 15 Jan 2019 15:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593775; cv=none; d=google.com; s=arc-20160816; b=u92ACN3XvO8gXATcgRn/AwjgOWfKfeLMM/fTxzvK2MroWp893PVZKAtSITfxD1KD0V 6OFs7lnlNW4JiSW5/yoitF52LZ9V29yoxhryevf7DuZDN0DpRsefz3LAW/P6sgK0d7wg UKrVW59IbIPwOho7jveQoKn2nCA5lNjbMBVSfmSVVqJOeasG6gNLAZRzJd3ky7SfhbjE IKmbckMHVTIGnnbmptGFRG2fNKkysvjK5US7HCyVq23ntYTtdzPJAtuc/lA6dfKOT3zJ 4HGUgbxLv3AWUPIrLokL2Qu8ay8N4st3feVhpRZj3KIkW9Y5q5pO/8XzpPqHnIQ1I9hY TEKw== 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=hmJLv9zod0KAXT0BrgzkE1E9z59zVifOkSf3jYPGor0=; b=RBn34h1ND7dQJEoPRe1Mciqi9b7gQmH3p541IZI6OtXqUtxx5SuWVwSvUOkzW97wUi QpYhWa/zBbb/Yzn1czEGlDD3QvH58RniKtZa3OTrqsEPWUiizkzIh6ZwFzdlvuDsIUEZ aRpydZC/VAmwmdpFs/X5fhEpBRkh4M7rauluxTLKzlZ+J01PmwYdiGMzwtQq2sJVQTyo lRG7getTapSATA5KIwInjNr6BsZn8I8LD7oJYHp1VLc+4RoNGVBkPisn/ZcETwpK4C/A +qx3WknFY1d6LXhMpLZHMeMlA0R73I83V1FqIWNVNoUt3w33So9nBFqnBPvPSYDKUPYS uhew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=acOOao4O; 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 o68si5050935pfo.140.2019.01.15.15.09.19; Tue, 15 Jan 2019 15:09:35 -0800 (PST) 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=acOOao4O; 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 S1731483AbfAOQs2 (ORCPT + 99 others); Tue, 15 Jan 2019 11:48:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:34604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728952AbfAOQpA (ORCPT ); Tue, 15 Jan 2019 11:45:00 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 9463E20675; Tue, 15 Jan 2019 16:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570699; bh=9VcXK7Kf90SQ2pSiL2o8GAnDgW+CGDI79CM0DW/z2Rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=acOOao4OiY5fkOjubmkslmXU+1Aqvi5iTA/ATnPvKNf6VGLEatuA1nGcyvikwQQ+4 K25MbnFainA2BCzqGNufVYsa1WOvzI9iuRXwoiQ1SOMQWMQ6o6JIfFw1JPnbnoF97y fl1aYErezDvDuJ4fwdFEiPzPO51rd+Xdt1MMWo3k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , "Rafael J. Wysocki" Subject: [PATCH 4.20 31/57] ACPI: power: Skip duplicate power resource references in _PRx Date: Tue, 15 Jan 2019 17:36:12 +0100 Message-Id: <20190115154912.454424323@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154910.734892368@linuxfoundation.org> References: <20190115154910.734892368@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede commit 7d7b467cb95bf29597b417d4990160d4ea6d69b9 upstream. Some ACPI tables contain duplicate power resource references like this: Name (_PR0, Package (0x04) // _PR0: Power Resources for D0 { P28P, P18P, P18P, CLK4 }) This causes a WARN_ON in sysfs_add_link_to_group() because we end up adding a link to the same acpi_device twice: sysfs: cannot create duplicate filename '/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/808622C1:00/OVTI2680:00/power_resources_D0/LNXPOWER:0a' CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.12-301.fc29.x86_64 #1 Hardware name: Insyde CherryTrail/Type2 - Board Product Name, BIOS jumperx.T87.KFBNEEA02 04/13/2016 Call Trace: dump_stack+0x5c/0x80 sysfs_warn_dup.cold.3+0x17/0x2a sysfs_do_create_link_sd.isra.2+0xa9/0xb0 sysfs_add_link_to_group+0x30/0x50 acpi_power_expose_list+0x74/0xa0 acpi_power_add_remove_device+0x50/0xa0 acpi_add_single_object+0x26b/0x5f0 acpi_bus_check_add+0xc4/0x250 ... To address this issue, make acpi_extract_power_resources() check for duplicates and simply skip them when found. Cc: All applicable Signed-off-by: Hans de Goede [ rjw: Subject & changelog, comments ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/power.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -131,6 +131,23 @@ void acpi_power_resources_list_free(stru } } +static bool acpi_power_resource_is_dup(union acpi_object *package, + unsigned int start, unsigned int i) +{ + acpi_handle rhandle, dup; + unsigned int j; + + /* The caller is expected to check the package element types */ + rhandle = package->package.elements[i].reference.handle; + for (j = start; j < i; j++) { + dup = package->package.elements[j].reference.handle; + if (dup == rhandle) + return true; + } + + return false; +} + int acpi_extract_power_resources(union acpi_object *package, unsigned int start, struct list_head *list) { @@ -150,6 +167,11 @@ int acpi_extract_power_resources(union a err = -ENODEV; break; } + + /* Some ACPI tables contain duplicate power resource references */ + if (acpi_power_resource_is_dup(package, start, i)) + continue; + err = acpi_add_power_resource(rhandle); if (err) break;