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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A812C4338F for ; Mon, 26 Jul 2021 16:34:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3811B60F91 for ; Mon, 26 Jul 2021 16:34:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239553AbhGZPxa (ORCPT ); Mon, 26 Jul 2021 11:53:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:49214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233770AbhGZPck (ORCPT ); Mon, 26 Jul 2021 11:32:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 80256604AC; Mon, 26 Jul 2021 16:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315988; bh=gRO08aN6NLVwr78x0am/cMJ/XPtjSjttuudzOiZyBAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKUQRx7pDAa3r9c12bk7o78+WUH82gFalpnl2peolwA4bwhpnfO6uj1RywkbCtm3h b3pVSd4gKwqXh8IDue/yjoMHUAFCh4eCaTBj9AiaIzju8XS42b/tFd2uuP024hAWvh skDWlz2oSnf4TMGaAufXslMRsu4vwASjPUsBgOko= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Scally , Andy Shevchenko , Linus Torvalds , Jens Axboe Subject: [PATCH 5.13 143/223] ACPI: fix NULL pointer dereference Date: Mon, 26 Jul 2021 17:38:55 +0200 Message-Id: <20210726153850.912570677@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@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 commit fc68f42aa737dc15e7665a4101d4168aadb8e4c4 upstream. 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: Greg Kroah-Hartman --- include/acpi/acpi_bus.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -711,7 +711,8 @@ static inline struct acpi_device *acpi_d static inline void acpi_dev_put(struct acpi_device *adev) { - put_device(&adev->dev); + if (adev) + put_device(&adev->dev); } #else /* CONFIG_ACPI */