qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 09/14] sdhci: refactor common sysbus/pci unreali


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 09/14] sdhci: refactor common sysbus/pci unrealize() into sdhci_unrealizefn()
Date: Thu, 14 Dec 2017 15:07:06 -0300

On Thu, Dec 14, 2017 at 2:46 PM, Alistair Francis
<address@hidden> wrote:
> On Wed, Dec 13, 2017 at 11:58 AM, Philippe Mathieu-Daudé
> <address@hidden> wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
>> ---
>>  hw/sd/sdhci.c | 21 ++++++++++++++++++---
>>  1 file changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
>> index 893be0e606..044e3d62f1 100644
>> --- a/hw/sd/sdhci.c
>> +++ b/hw/sd/sdhci.c
>> @@ -31,6 +31,7 @@
>>  #include "hw/sd/sdhci.h"
>>  #include "sdhci-internal.h"
>>  #include "sd-internal.h"
>> +#include "qapi/error.h"
>>  #include "qemu/log.h"
>>
>>  /* host controller debug messages */
>> @@ -1191,17 +1192,21 @@ static void sdhci_realizefn(SDHCIState *s, Error 
>> **errp)
>>                            SDHC_REGISTERS_MAP_SIZE);
>>  }
>>
>> +static void sdhci_unrealizefn(SDHCIState *s, Error **errp)
>> +{
>> +    g_free(s->fifo_buffer);
>> +    s->fifo_buffer = NULL;
>
> I don't think setting this to NULL is required. Shouldn't g_free() do
> that for you?

You are right, good eye :) I didn't notice, this was just code
movement from the current code.

Indeed g_free() doesn't free() if the pointer is NULL, however since
it doesn't have access to the pointer address it can't set it to NULL.
In some case it matters (RCU code maybe?) but I just checked and it
this case it doesn't, so I'll drop this line.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]