All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Jens Axboe <axboe@kernel.dk>, Daniel Scally <djrscally@gmail.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-acpi@vger.kernel.org, devel@acpica.org
Subject: [PATCH AUTOSEL 5.10 17/17] ACPI: fix NULL pointer dereference
Date: Tue, 27 Jul 2021 09:19:38 -0400	[thread overview]
Message-ID: <20210727131938.834920-17-sashal@kernel.org> (raw)
In-Reply-To: <20210727131938.834920-1-sashal@kernel.org>

From: Linus Torvalds <torvalds@linux-foundation.org>

[ 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 <axboe@kernel.dk>
Tested-by: Daniel Scally <djrscally@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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


      parent reply	other threads:[~2021-07-27 13:30 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 13:19 [PATCH AUTOSEL 5.10 01/17] regulator: rtmv20: Fix wrong mask for strobe-polarity-high Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 02/17] regulator: rt5033: Fix n_voltages settings for BUCK and LDO Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 03/17] spi: stm32h7: fix full duplex irq handler handling Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 04/17] ASoC: tlv320aic31xx: fix reversed bclk/wclk master bits Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 05/17] USB: core: Fix incorrect pipe calculation in do_proc_control() Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 06/17] r8152: Fix potential PM refcount imbalance Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 07/17] qed: fix possible unpaired spin_{un}lock_bh in _qed_mcp_cmd_and_union() Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 08/17] ASoC: rt5682: Fix the issue of garbled recording after powerd_dbus_suspend Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 09/17] mt7530 fix mt7530_fdb_write vid missing ivl bit Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 10/17] net: Fix zero-copy head len calculation Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 11/17] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 12/17] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 13/17] efi/mokvar: Reserve the table only if it is in boot services data Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 14/17] nvme: fix nvme_setup_command metadata trace event Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-08-05 12:17   ` Pavel Machek
2021-08-05 12:17     ` Pavel Machek
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 15/17] drm/amd/display: Fix comparison error in dcn21 DML Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` [PATCH AUTOSEL 5.10 16/17] drm/amd/display: Fix max vstartup calculation for modes with borders Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19   ` Sasha Levin
2021-07-27 13:19 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210727131938.834920-17-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=devel@acpica.org \
    --cc=djrscally@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.