From: Seung-Woo Kim <sw0312.kim@samsung.com>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>,
Rob Clark <robclark@freedesktop.org>,
ML dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH libdrm] tests/exynos: fix memory issues of error path in g2d test
Date: Mon, 20 Mar 2017 09:14:39 +0900 [thread overview]
Message-ID: <58CF1EEF.80009@samsung.com> (raw)
In-Reply-To: <CACvgo51MMt8eeY=nM-j5REBnAUDeeGhtCdinK9NgrKKZheFKrA@mail.gmail.com>
Hello Emil,
Thanks for comment.
On 2017년 03월 20일 09:08, Emil Velikov wrote:
> Hi Seung-Woo Kim,
>
> On 16 March 2017 at 02:00, Seung-Woo Kim <sw0312.kim@samsung.com> wrote:
>> This patch fixes memory issues including NULL deference and leak
>> in g2d test in error path.
>>
>> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
>> ---
>> tests/exynos/exynos_fimg2d_test.c | 13 +++++++------
>> 1 files changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/tests/exynos/exynos_fimg2d_test.c b/tests/exynos/exynos_fimg2d_test.c
>> index 797fb6e..2177e08 100644
>> --- a/tests/exynos/exynos_fimg2d_test.c
>> +++ b/tests/exynos/exynos_fimg2d_test.c
>> @@ -59,7 +59,6 @@ static void connector_find_mode(int fd, struct connector *c,
>> if (!connector) {
>> fprintf(stderr, "could not get connector %i: %s\n",
>> resources->connectors[i], strerror(errno));
>> - drmModeFreeConnector(connector);
>> continue;
>> }
>>
>> @@ -98,7 +97,6 @@ static void connector_find_mode(int fd, struct connector *c,
>> if (!c->encoder) {
>> fprintf(stderr, "could not get encoder %i: %s\n",
>> resources->encoders[i], strerror(errno));
>> - drmModeFreeEncoder(c->encoder);
>> continue;
>> }
>>
>> @@ -264,7 +262,8 @@ static int g2d_copy_test(struct exynos_device *dev, struct exynos_bo *src,
>> userptr = (unsigned long)malloc(size);
>> if (!userptr) {
>> fprintf(stderr, "failed to allocate userptr.\n");
>> - return -EFAULT;
>> + ret = -EFAULT;
>> + goto fail;
> Even if you have the best of intentions, but there's yet another bug
> in the existing code :-\
>
> Namely: we always return 0 even on error - i.e. the "return 0", after
> the g2d_fini() must be "return ret"
> This applies to all the tests, afaics.
You are right. I will fix it.
>
>
>> @@ -755,7 +756,7 @@ int main(int argc, char **argv)
>>
>> dev = exynos_device_create(fd);
>> if (!dev) {
>> - drmClose(dev->fd);
>> + drmClose(fd);
> Seems correct, but an alternative (better IMHO) solution is to:
> - flip/fix the call drmClose() <> exynos_device_destroy() order in
> err_drm_close.
> - use "fd" in exynos_device_destroy's drmClose.
> - add separate label and use it in the above case.
Ok, I will add error label.
>
> Can you give this a try, please ?
After fixing as your comment, I will send v2.
Regards,
- Seung-Woo Kim
>
> Thanks
> Emil
>
>
>
--
Seung-Woo Kim
Samsung Software R&D Center
--
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-03-20 0:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170316015952epcas1p20a285e6029d1b94cb32b1fca2aeb1d18@epcas1p2.samsung.com>
2017-03-16 2:00 ` [PATCH libdrm] tests/exynos: fix memory issues of error path in g2d test Seung-Woo Kim
2017-03-20 0:08 ` Emil Velikov
2017-03-20 0:14 ` Seung-Woo Kim [this message]
2017-03-20 0:52 ` [PATCH] tests/exynos: fix invalid code " Seung-Woo Kim
2017-04-03 16:28 ` Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58CF1EEF.80009@samsung.com \
--to=sw0312.kim@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=robclark@freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).