From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1C2FC04A95 for ; Wed, 28 Sep 2022 19:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234383AbiI1ThP (ORCPT ); Wed, 28 Sep 2022 15:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234346AbiI1ThM (ORCPT ); Wed, 28 Sep 2022 15:37:12 -0400 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E78435F115; Wed, 28 Sep 2022 12:37:08 -0700 (PDT) Received: by mail-qv1-f50.google.com with SMTP id p3so3250076qvz.6; Wed, 28 Sep 2022 12:37:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=OnNyNviAMrTN7Xzf5rjzt1Cctz22dmk9+rbhre1TNPM=; b=edBpeVchMfYJ8nZ5wvDb68/2NHUzlq+Qp6/RhJ9R0szerHTxYq1UjN7Zm73arhgLNn h/xx2VnK3CttGz/vcx1cwNc91oemLJIp28N/pYuFE3lQN4mV76iNTpAr5rbWncc2KWJq ld4epTeCX4OqaJ4yhZVZLwNh3wfzzMhht0U+neNu9ifepIaATKKjFKq1kry11cxh3F+p RBbo1DR7k16RniWxBawKhroaCabchCJ6/YqGPTN1c5guhsL0adH9SrLtpLPqIVDcGmOD MauL+lcZmQFahz8KaJByQebeUjikACSV2rfJtEifUECSLLkcB1guPvu5Rh9PGvP/u7qP LcQg== X-Gm-Message-State: ACrzQf01L9TqbVDtxbZ7FBnuyFNE3B/Ajpa5A8B0myOom0rtnaKGTz5Z Tpik6Sa/EC1vhw222edRYaYUjhbFUNjoJusBtykpU2vV X-Google-Smtp-Source: AMsMyM6hnDwyC5sax1NuHQQfb3aCyw02PG5jPXTvbhNAdOcp+pnjAZtht+l6KJYLbyUX0pRDrxcm8mrvrltZ/YciL2s= X-Received: by 2002:a0c:f3cb:0:b0:4af:a435:2c1b with SMTP id f11-20020a0cf3cb000000b004afa4352c1bmr496757qvm.130.1664393827995; Wed, 28 Sep 2022 12:37:07 -0700 (PDT) MIME-Version: 1.0 References: <20220928161935.31913-1-mario.limonciello@amd.com> In-Reply-To: <20220928161935.31913-1-mario.limonciello@amd.com> From: "Rafael J. Wysocki" Date: Wed, 28 Sep 2022 21:36:56 +0200 Message-ID: Subject: Re: [PATCH 1/2] ACPI: x86: s2idle: Fix a NULL pointer dereference To: Mario Limonciello Cc: Philipp Zabel , "Rafael J. Wysocki" , "Luke D. Jones" , Shyam Sundar S K , Richard Gong , "Rafael J. Wysocki" , Len Brown , ACPI Devel Maling List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 28, 2022 at 6:19 PM Mario Limonciello wrote: > > Ryzen 7000 (Raphael) introduced AMDI0008 for _HID. This ID was added > in commit ed470febf837 ("ACPI: PM: s2idle: Add support for upcoming AMD > uPEP HID AMDI008"), but then removed in favor of aligning all new IDs > to Rembrandt support in commit fd894f05cf30 ("ACPI: x86: s2idle: If a > new AMD _HID is missing assume Rembrandt"). > > Unfortunately there was a mistake in commit 100a57379380 ("ACPI: x86: > s2idle: Move _HID handling for AMD systems into structures") that can > lead to a NULL pointer dereference accessing `dev_id->driver_data` in > the sentinel of `amd_hid_ids`. Fix this dereference. > > Reported-by: Richard Gong > Fixes: 100a57379380 ("ACPI: x86: s2idle: Move _HID handling for AMD systems into structures") > Signed-off-by: Mario Limonciello > --- > drivers/acpi/x86/s2idle.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c > index eedd21d8a284..3ae2ba74de92 100644 > --- a/drivers/acpi/x86/s2idle.c > +++ b/drivers/acpi/x86/s2idle.c > @@ -470,7 +470,7 @@ static int lps0_device_attach(struct acpi_device *adev, > for (dev_id = &amd_hid_ids[0]; dev_id->id[0]; dev_id++) > if (acpi_dev_hid_uid_match(adev, dev_id->id, NULL)) > break; > - if (dev_id) > + if (dev_id->id[0]) > data = (const struct amd_lps0_hid_device_data *) dev_id->driver_data; > else > data = &amd_rembrandt; > -- Applied along with the [2/2], thanks!