mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 04:47:05 +00:00
ACPI: extlog: fix NULL pointer dereference check
[ Upstream commit 72d9b9747e
]
The gcc plugin -fanalyzer [1] tries to detect various
patterns of incorrect behaviour. The tool reports:
drivers/acpi/acpi_extlog.c: In function ‘extlog_exit’:
drivers/acpi/acpi_extlog.c:307:12: warning: check of ‘extlog_l1_addr’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]
|
| 306 | ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
| | |
| | (1) pointer ‘extlog_l1_addr’ is dereferenced here
| 307 | if (extlog_l1_addr)
| | ~
| | |
| | (2) pointer ‘extlog_l1_addr’ is checked for NULL here but it was already dereferenced at (1)
|
Fix the NULL pointer dereference check in extlog_exit().
Link: https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Static-Analyzer-Options.html # [1]
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
0d2adafba9
commit
d2049af7dd
1 changed files with 3 additions and 2 deletions
|
@ -316,9 +316,10 @@ static void __exit extlog_exit(void)
|
|||
{
|
||||
edac_set_report_status(old_edac_report_status);
|
||||
mce_unregister_decode_chain(&extlog_mce_dec);
|
||||
((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
|
||||
if (extlog_l1_addr)
|
||||
if (extlog_l1_addr) {
|
||||
((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
|
||||
acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
|
||||
}
|
||||
if (elog_addr)
|
||||
acpi_os_unmap_iomem(elog_addr, elog_size);
|
||||
release_mem_region(elog_base, elog_size);
|
||||
|
|
Loading…
Reference in a new issue