* [Qemu-devel] [PATCH] spapr_events: use QTAILQ_FOREACH_SAFE() in spapr_clear_pending_events()
@ 2017-09-12 18:48 Greg Kurz
2017-09-13 0:35 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Greg Kurz @ 2017-09-12 18:48 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson, Daniel Henrique Barboza, Peter Maydell
QTAILQ_FOREACH_SAFE() must be used when removing the current element
inside the loop block.
This fixes a user-after-free error introduced by commit 56258174238eb
and reported by Coverity (CID 1381017).
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/spapr_events.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 66b8164f30be..e377fc7ddea2 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -702,9 +702,9 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineState *spapr,
void spapr_clear_pending_events(sPAPRMachineState *spapr)
{
- sPAPREventLogEntry *entry = NULL;
+ sPAPREventLogEntry *entry = NULL, *next_entry;
- QTAILQ_FOREACH(entry, &spapr->pending_events, next) {
+ QTAILQ_FOREACH_SAFE(entry, &spapr->pending_events, next, next_entry) {
QTAILQ_REMOVE(&spapr->pending_events, entry, next);
g_free(entry->extended_log);
g_free(entry);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr_events: use QTAILQ_FOREACH_SAFE() in spapr_clear_pending_events()
2017-09-12 18:48 [Qemu-devel] [PATCH] spapr_events: use QTAILQ_FOREACH_SAFE() in spapr_clear_pending_events() Greg Kurz
@ 2017-09-13 0:35 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2017-09-13 0:35 UTC (permalink / raw)
To: Greg Kurz; +Cc: qemu-devel, qemu-ppc, Daniel Henrique Barboza, Peter Maydell
[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]
On Tue, Sep 12, 2017 at 08:48:05PM +0200, Greg Kurz wrote:
> QTAILQ_FOREACH_SAFE() must be used when removing the current element
> inside the loop block.
>
> This fixes a user-after-free error introduced by commit 56258174238eb
> and reported by Coverity (CID 1381017).
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Applied to ppc-for-2.11.
> ---
> hw/ppc/spapr_events.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
> index 66b8164f30be..e377fc7ddea2 100644
> --- a/hw/ppc/spapr_events.c
> +++ b/hw/ppc/spapr_events.c
> @@ -702,9 +702,9 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineState *spapr,
>
> void spapr_clear_pending_events(sPAPRMachineState *spapr)
> {
> - sPAPREventLogEntry *entry = NULL;
> + sPAPREventLogEntry *entry = NULL, *next_entry;
>
> - QTAILQ_FOREACH(entry, &spapr->pending_events, next) {
> + QTAILQ_FOREACH_SAFE(entry, &spapr->pending_events, next, next_entry) {
> QTAILQ_REMOVE(&spapr->pending_events, entry, next);
> g_free(entry->extended_log);
> g_free(entry);
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-13 1:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 18:48 [Qemu-devel] [PATCH] spapr_events: use QTAILQ_FOREACH_SAFE() in spapr_clear_pending_events() Greg Kurz
2017-09-13 0:35 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).