From: Greg Kurz <groug@kaod.org>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: qemu-devel@nongnu.org, xen-devel@lists.xen.org,
anthony.perard@citrix.com, aneesh.kumar@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2 1/3] xen/9pfs: fix two resource leaks on error paths, discovered by Coverity
Date: Tue, 9 May 2017 22:29:26 +0200 [thread overview]
Message-ID: <20170509222926.293ab520@bahia> (raw)
In-Reply-To: <1494356693-13190-1-git-send-email-sstabellini@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]
On Tue, 9 May 2017 12:04:51 -0700
Stefano Stabellini <sstabellini@kernel.org> wrote:
> CID: 1374836
>
> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
> CC: anthony.perard@citrix.com
> CC: groug@kaod.org
> CC: aneesh.kumar@linux.vnet.ibm.com
> ---
> hw/9pfs/xen-9p-backend.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> index 9c7f41a..a1fdede 100644
> --- a/hw/9pfs/xen-9p-backend.c
> +++ b/hw/9pfs/xen-9p-backend.c
> @@ -332,12 +332,14 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
> str = g_strdup_printf("ring-ref%u", i);
> if (xenstore_read_fe_int(&xen_9pdev->xendev, str,
> &xen_9pdev->rings[i].ref) == -1) {
> + g_free(str);
> goto out;
> }
> g_free(str);
I would rather do something like:
int ret;
[...]
str = g_strdup_printf("ring-ref%u", i);
ret = xenstore_read_fe_int(&xen_9pdev->xendev, str,
&xen_9pdev->rings[i].ref);
g_free(str);
if (ret == -1) {
goto out;
}
but this is a matter of taste and you own this code so:
Reviewed-by: Greg Kurz <groug@kaod.org>
> str = g_strdup_printf("event-channel-%u", i);
> if (xenstore_read_fe_int(&xen_9pdev->xendev, str,
> &xen_9pdev->rings[i].evtchn) == -1) {
> + g_free(str);
> goto out;
> }
> g_free(str);
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Greg Kurz <groug@kaod.org>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: anthony.perard@citrix.com, aneesh.kumar@linux.vnet.ibm.com,
qemu-devel@nongnu.org, xen-devel@lists.xen.org
Subject: Re: [PATCH v2 1/3] xen/9pfs: fix two resource leaks on error paths, discovered by Coverity
Date: Tue, 9 May 2017 22:29:26 +0200 [thread overview]
Message-ID: <20170509222926.293ab520@bahia> (raw)
In-Reply-To: <1494356693-13190-1-git-send-email-sstabellini@kernel.org>
[-- Attachment #1.1: Type: text/plain, Size: 1596 bytes --]
On Tue, 9 May 2017 12:04:51 -0700
Stefano Stabellini <sstabellini@kernel.org> wrote:
> CID: 1374836
>
> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
> CC: anthony.perard@citrix.com
> CC: groug@kaod.org
> CC: aneesh.kumar@linux.vnet.ibm.com
> ---
> hw/9pfs/xen-9p-backend.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> index 9c7f41a..a1fdede 100644
> --- a/hw/9pfs/xen-9p-backend.c
> +++ b/hw/9pfs/xen-9p-backend.c
> @@ -332,12 +332,14 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
> str = g_strdup_printf("ring-ref%u", i);
> if (xenstore_read_fe_int(&xen_9pdev->xendev, str,
> &xen_9pdev->rings[i].ref) == -1) {
> + g_free(str);
> goto out;
> }
> g_free(str);
I would rather do something like:
int ret;
[...]
str = g_strdup_printf("ring-ref%u", i);
ret = xenstore_read_fe_int(&xen_9pdev->xendev, str,
&xen_9pdev->rings[i].ref);
g_free(str);
if (ret == -1) {
goto out;
}
but this is a matter of taste and you own this code so:
Reviewed-by: Greg Kurz <groug@kaod.org>
> str = g_strdup_printf("event-channel-%u", i);
> if (xenstore_read_fe_int(&xen_9pdev->xendev, str,
> &xen_9pdev->rings[i].evtchn) == -1) {
> + g_free(str);
> goto out;
> }
> g_free(str);
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
[-- Attachment #2: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-05-09 20:29 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 19:04 [Qemu-devel] [PATCH v2 1/3] xen/9pfs: fix two resource leaks on error paths, discovered by Coverity Stefano Stabellini
2017-05-09 19:04 ` Stefano Stabellini
2017-05-09 19:04 ` [Qemu-devel] [PATCH v2 2/3] Check the return value of fcntl in qemu_set_cloexec Stefano Stabellini
2017-05-09 19:04 ` Stefano Stabellini
2017-05-09 19:20 ` [Qemu-devel] " Eric Blake
2017-05-09 19:20 ` Eric Blake
2017-05-09 20:31 ` [Qemu-devel] " Greg Kurz
2017-05-09 20:31 ` Greg Kurz
2017-05-11 7:55 ` [Qemu-devel] " Paolo Bonzini
2017-05-11 7:55 ` Paolo Bonzini
2017-05-16 18:53 ` [Qemu-devel] " Stefano Stabellini
2017-05-16 18:53 ` Stefano Stabellini
2017-05-09 19:04 ` [Qemu-devel] [PATCH v2 3/3] xen: call qemu_set_cloexec instead of fcntl Stefano Stabellini
2017-05-09 19:04 ` Stefano Stabellini
2017-05-09 19:21 ` [Qemu-devel] " Eric Blake
2017-05-09 19:21 ` Eric Blake
2017-05-09 20:54 ` [Qemu-devel] " Greg Kurz
2017-05-09 20:54 ` Greg Kurz
2017-05-09 19:20 ` [Qemu-devel] [PATCH v2 1/3] xen/9pfs: fix two resource leaks on error paths, discovered by Coverity Eric Blake
2017-05-09 19:20 ` Eric Blake
2017-05-09 19:28 ` Eric Blake
2017-05-09 19:28 ` Eric Blake
2017-05-09 19:47 ` Stefano Stabellini
2017-05-09 19:47 ` Stefano Stabellini
2017-05-09 20:29 ` Greg Kurz [this message]
2017-05-09 20:29 ` Greg Kurz
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=20170509222926.293ab520@bahia \
--to=groug@kaod.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=anthony.perard@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.