[Mesa-dev] [PATCH] st/mesa: fix resource leak in try_pbo_readpixels

Nicolai Hähnle nhaehnle at gmail.com
Thu Jun 2 20:57:48 UTC 2016


On 02.06.2016 22:53, Ilia Mirkin wrote:
> On Thu, Jun 2, 2016 at 4:50 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>
>> Found by inspection after seeing
>> https://bugs.freedesktop.org/show_bug.cgi?id=96343
>> ---
>>   src/mesa/state_tracker/st_cb_readpixels.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
>> index 6df3a39..f42ff20 100644
>> --- a/src/mesa/state_tracker/st_cb_readpixels.c
>> +++ b/src/mesa/state_tracker/st_cb_readpixels.c
>> @@ -170,6 +170,8 @@ try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
>>         image.u.buf.last_element = addr.last_element;
>>
>>         cso_set_shader_images(cso, PIPE_SHADER_FRAGMENT, 0, 1, &image);
>> +
>> +      pipe_resource_reference(&image.resource, NULL);
>
> Instead would it be cleaner to not do this at all, and just do
>
> image.resource = addr.buffer
>
> above, instead of doing the whole reference thing. As far as I can
> tell, you're not protecting against anything by grabbing the extra
> reference.

Sure, that works as well. Somehow I was thinking "pipe_image_view holds 
a reference", but now that I actually look at st_atom_image.c, it also 
doesn't do this. I'll change it.

Nicolai

>
>    -ilia
>


More information about the mesa-dev mailing list