Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp479011pxt; Fri, 6 Aug 2021 06:39:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDMH5q74EAIIae+ZwbtsT3zfaySe6HrIf0kgIzolrOj4SuBszMlwEP6pI3MfycVokk9rLg X-Received: by 2002:a17:906:5aca:: with SMTP id x10mr10118122ejs.414.1628257193247; Fri, 06 Aug 2021 06:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628257193; cv=none; d=google.com; s=arc-20160816; b=SS3U32WsJeTWIu6rGZRlN6ytq2bak12hsIXcAeeqDTJPverwxCgcmGbgFtzRg2FDs3 g478eVjbq6Uhl8NoySKELMlI+sScrM6r40OHkboSBE3tFM+zeAYGBs8HkbMPM8KJJCLG 6NxdK69VkFvqWlLHuAkARqqXQnzJexksHaNTXhxPVqgrROzztj6EcjjCZDuMTtg8rVkq fbf4DlJeePLgfpcXxprNXUdV5LmB/H8Jbyz9vH+UdlzHPDXPsimboGXAJkhwO7XUrlsB 399jmVI9dky6RGGwn/HVUmH9UfltVF2T0VVuTWfuAdtds8cvztOYKoILlMDFGZmp/OJ5 B4Gg== 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=G+EbACqBMCc4xpdXY7AwSoW3LQNi1qYHY1AWgFfyksU=; b=izZXDRirPwDJ1bpvV5DO11hAVfLysEhdYrNl7sNaxUpxyN+OeM6Oj+5jooA3264HA0 70dy3t10muvWqEvPfn5Tmj2IN4uYK8emzAq+DEpMy1t3hS5+yx9dSdv5raX4cOEC9A4z fl45aY7vsHMD6FByur/69dBGybC7FrIueiY1oKJGiuAqS+wkwgeuKkCcA4PzyEUKAtGL rNktwmoEt2OIAwk6QJp2tQH5tjqwG3fgZW8xSsmTx0CLEAjEQfCmPBIlDRA/htX8qNHH hMQtRnEaNLEd/5sOPb9t9bvluO0iJumG/XNuC5NlUUFpiquv7V+oD6Zndad7aijQVRtL 9dZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tvJx0vIW; 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 f4si9017806ejl.218.2021.08.06.06.39.29; Fri, 06 Aug 2021 06:39:53 -0700 (PDT) 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=tvJx0vIW; 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 S244578AbhHFIXR (ORCPT + 99 others); Fri, 6 Aug 2021 04:23:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:51310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243970AbhHFIUC (ORCPT ); Fri, 6 Aug 2021 04:20:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6297A61207; Fri, 6 Aug 2021 08:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628237985; bh=m8eVRp7kvqRylifcK3gNGxLsO1GYKoZFlzGmAUzr1Bs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tvJx0vIWjk5GC5wv0DiikEdim/DbG0gqRl/N+XEIwBgS1ocBIrjlzQZY3obmQmMFS B7jxqF6oOWt3dAR9g6+vblOfhJzTetLi0LhsQP6PHIoGmD6o8nKaJG35cipxA7HA5H 33VHYFZOfu9O7D4kA5+E1JZOMx1Xs2k7DCs7M0ys= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Scally , Andy Shevchenko , Linus Torvalds , Sasha Levin , Jens Axboe Subject: [PATCH 5.10 19/30] ACPI: fix NULL pointer dereference Date: Fri, 6 Aug 2021 10:16:57 +0200 Message-Id: <20210806081113.780004075@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806081113.126861800@linuxfoundation.org> References: <20210806081113.126861800@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: Linus Torvalds [ Upstream commit fc68f42aa737dc15e7665a4101d4168aadb8e4c4 ] Commit 71f642833284 ("ACPI: utils: Fix reference counting in for_each_acpi_dev_match()") started doing "acpi_dev_put()" on a pointer that was possibly NULL. That fails miserably, because that helper inline function is not set up to handle that case. Just make acpi_dev_put() silently accept a NULL pointer, rather than calling down to put_device() with an invalid offset off that NULL pointer. Link: https://lore.kernel.org/lkml/a607c149-6bf6-0fd0-0e31-100378504da2@kernel.dk/ Reported-and-tested-by: Jens Axboe Tested-by: Daniel Scally Cc: Andy Shevchenko Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- include/acpi/acpi_bus.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 37dac195adbb..6ad3b89a8a2e 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -689,7 +689,8 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv); static inline void acpi_dev_put(struct acpi_device *adev) { - put_device(&adev->dev); + if (adev) + put_device(&adev->dev); } #else /* CONFIG_ACPI */ -- 2.30.2