* re: ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to new TermList grammar for table loading
@ 2016-06-04 14:04 Dan Carpenter
2016-06-06 10:05 ` Zheng, Lv
2016-06-06 10:26 ` [PATCH] ACPICA: Namespace: Fix wrong cleanup code in acpi_ns_execute_table() Lv Zheng
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-06-04 14:04 UTC (permalink / raw)
To: lv.zheng; +Cc: linux-acpi
Hello Lv Zheng,
The patch 0bfd2f1ec274: "ACPICA: ACPI 2.0, Interpreter: Fix MLC
issues by switching to new TermList grammar for table loading" from
May 13, 2016, leads to the following static checker warning:
drivers/acpi/acpica/nsparse.c:139 acpi_ns_execute_table()
error: we previously assumed 'info' could be null (see line 110)
drivers/acpi/acpica/nsparse.c
135 (void)acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
136
137 cleanup:
138 acpi_ut_remove_reference(method_obj);
139 ACPI_FREE(info->full_pathname);
^^^^^^^^^^^^^^^^^^^
Archetypal one err bug. It's better to unwind in reverse order from how
you allacted things and only free things you have allocated. Use more
than one label. Also you can use more descriptive label names.
(void)acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
free_pathname:
ACPI_FREE(info->full_pathname);
free_info:
ACPI_FREE(info);
remove_method:
acpi_ut_remove_reference(method_obj);
return_ACPI_STATUS(status);
140 info->full_pathname = NULL;
141 ACPI_FREE(info);
142 return_ACPI_STATUS(status);
143 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to new TermList grammar for table loading
2016-06-04 14:04 ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to new TermList grammar for table loading Dan Carpenter
@ 2016-06-06 10:05 ` Zheng, Lv
2016-06-06 10:24 ` Dan Carpenter
2016-06-06 10:26 ` [PATCH] ACPICA: Namespace: Fix wrong cleanup code in acpi_ns_execute_table() Lv Zheng
1 sibling, 1 reply; 4+ messages in thread
From: Zheng, Lv @ 2016-06-06 10:05 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-acpi@vger.kernel.org
Hi, Dan
Thanks for the report.
I'll double check it with C=2 enabled build.
Best regards
-Lv
> From: linux-acpi-owner@vger.kernel.org [mailto:linux-acpi-
> owner@vger.kernel.org] On Behalf Of Dan Carpenter
> Subject: re: ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to
> new TermList grammar for table loading
>
> Hello Lv Zheng,
>
> The patch 0bfd2f1ec274: "ACPICA: ACPI 2.0, Interpreter: Fix MLC
> issues by switching to new TermList grammar for table loading" from
> May 13, 2016, leads to the following static checker warning:
>
> drivers/acpi/acpica/nsparse.c:139 acpi_ns_execute_table()
> error: we previously assumed 'info' could be null (see line 110)
>
> drivers/acpi/acpica/nsparse.c
> 135 (void)acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
> 136
> 137 cleanup:
> 138 acpi_ut_remove_reference(method_obj);
> 139 ACPI_FREE(info->full_pathname);
> ^^^^^^^^^^^^^^^^^^^
> Archetypal one err bug. It's better to unwind in reverse order from how
> you allacted things and only free things you have allocated. Use more
> than one label. Also you can use more descriptive label names.
>
> (void)acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
>
> free_pathname:
> ACPI_FREE(info->full_pathname);
> free_info:
> ACPI_FREE(info);
> remove_method:
> acpi_ut_remove_reference(method_obj);
>
> return_ACPI_STATUS(status);
>
>
> 140 info->full_pathname = NULL;
> 141 ACPI_FREE(info);
> 142 return_ACPI_STATUS(status);
> 143 }
>
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to new TermList grammar for table loading
2016-06-06 10:05 ` Zheng, Lv
@ 2016-06-06 10:24 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-06-06 10:24 UTC (permalink / raw)
To: Zheng, Lv; +Cc: linux-acpi@vger.kernel.org
On Mon, Jun 06, 2016 at 10:05:12AM +0000, Zheng, Lv wrote:
> Hi, Dan
>
> Thanks for the report.
> I'll double check it with C=2 enabled build.
It's a Smatch warning.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ACPICA: Namespace: Fix wrong cleanup code in acpi_ns_execute_table()
2016-06-04 14:04 ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to new TermList grammar for table loading Dan Carpenter
2016-06-06 10:05 ` Zheng, Lv
@ 2016-06-06 10:26 ` Lv Zheng
1 sibling, 0 replies; 4+ messages in thread
From: Lv Zheng @ 2016-06-06 10:26 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-kernel, linux-acpi
An error was captured by the static checker. This patch fixes the issue.
introduced in:
Subject: ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to
new TermList grammar for table loading
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
drivers/acpi/acpica/nsparse.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 2452bf3..72893a9 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -135,10 +135,12 @@ acpi_ns_execute_table(u32 table_index, struct acpi_namespace_node *start_node)
(void)acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
cleanup:
- acpi_ut_remove_reference(method_obj);
- ACPI_FREE(info->full_pathname);
- info->full_pathname = NULL;
+ if (info) {
+ ACPI_FREE(info->full_pathname);
+ info->full_pathname = NULL;
+ }
ACPI_FREE(info);
+ acpi_ut_remove_reference(method_obj);
return_ACPI_STATUS(status);
}
--
1.7.10
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-06 10:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-04 14:04 ACPICA: ACPI 2.0, Interpreter: Fix MLC issues by switching to new TermList grammar for table loading Dan Carpenter
2016-06-06 10:05 ` Zheng, Lv
2016-06-06 10:24 ` Dan Carpenter
2016-06-06 10:26 ` [PATCH] ACPICA: Namespace: Fix wrong cleanup code in acpi_ns_execute_table() Lv Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox