diff mbox

[1/4] hw/display/cg3.c: Fix memory leak

Message ID 1432811625-13392-2-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao May 28, 2015, 11:13 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/display/cg3.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael Tokarev May 28, 2015, 11:55 a.m. UTC | #1
28.05.2015 14:13, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/display/cg3.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/display/cg3.c b/hw/display/cg3.c
> index 1e6ff2b..b86e5c0 100644
> --- a/hw/display/cg3.c
> +++ b/hw/display/cg3.c
> @@ -302,6 +302,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
>      if (fcode_filename) {
>          ret = load_image_targphys(fcode_filename, s->prom_addr,
>                                    FCODE_MAX_ROM_SIZE);
> +        g_free(fcode_filename);
>          if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
>              error_report("cg3: could not load prom '%s'", CG3_ROM_FILE);
>          }

BTW, here, maybe it is better to rework error message too,
to include the actual filename it tried to load, not the
base name of it.

Is the error fatal?

Thanks,

/mjt
Shannon Zhao May 28, 2015, 12:08 p.m. UTC | #2
On 2015/5/28 19:55, Michael Tokarev wrote:
> 28.05.2015 14:13, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> >  hw/display/cg3.c | 1 +
>> >  1 file changed, 1 insertion(+)
>> > 
>> > diff --git a/hw/display/cg3.c b/hw/display/cg3.c
>> > index 1e6ff2b..b86e5c0 100644
>> > --- a/hw/display/cg3.c
>> > +++ b/hw/display/cg3.c
>> > @@ -302,6 +302,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
>> >      if (fcode_filename) {
>> >          ret = load_image_targphys(fcode_filename, s->prom_addr,
>> >                                    FCODE_MAX_ROM_SIZE);
>> > +        g_free(fcode_filename);
>> >          if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
>> >              error_report("cg3: could not load prom '%s'", CG3_ROM_FILE);
>> >          }
> BTW, here, maybe it is better to rework error message too,
> to include the actual filename it tried to load, not the
> base name of it.
> 

So respin this and other patches?

> Is the error fatal?

If CG3_ROM_FILE is removed, it happens.
diff mbox

Patch

diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 1e6ff2b..b86e5c0 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -302,6 +302,7 @@  static void cg3_realizefn(DeviceState *dev, Error **errp)
     if (fcode_filename) {
         ret = load_image_targphys(fcode_filename, s->prom_addr,
                                   FCODE_MAX_ROM_SIZE);
+        g_free(fcode_filename);
         if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
             error_report("cg3: could not load prom '%s'", CG3_ROM_FILE);
         }