* [PATCH] xfs: fix two memory leaks in xfs_attr_list.c error paths
@ 2016-02-10 18:35 Mateusz Guzik
2016-02-10 20:38 ` Eric Sandeen
2016-02-12 9:27 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Mateusz Guzik @ 2016-02-10 18:35 UTC (permalink / raw)
To: xfs; +Cc: stable
This plugs 2 trivial leaks in xfs_attr_shortform_list and
xfs_attr3_leaf_list_int.
Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
Cc: <stable@vger.kernel.org>
---
fs/xfs/xfs_attr_list.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
index 0ef7c2e..4fa1482 100644
--- a/fs/xfs/xfs_attr_list.c
+++ b/fs/xfs/xfs_attr_list.c
@@ -202,8 +202,10 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
sbp->namelen,
sbp->valuelen,
&sbp->name[sbp->namelen]);
- if (error)
+ if (error) {
+ kmem_free(sbuf);
return error;
+ }
if (context->seen_enough)
break;
cursor->offset++;
@@ -454,14 +456,13 @@ xfs_attr3_leaf_list_int(
args.rmtblkcnt = xfs_attr3_rmt_blocks(
args.dp->i_mount, valuelen);
retval = xfs_attr_rmtval_get(&args);
- if (retval)
- return retval;
- retval = context->put_listent(context,
- entry->flags,
- name_rmt->name,
- (int)name_rmt->namelen,
- valuelen,
- args.value);
+ if (!retval)
+ retval = context->put_listent(context,
+ entry->flags,
+ name_rmt->name,
+ (int)name_rmt->namelen,
+ valuelen,
+ args.value);
kmem_free(args.value);
} else {
retval = context->put_listent(context,
--
1.8.3.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: fix two memory leaks in xfs_attr_list.c error paths
2016-02-10 18:35 [PATCH] xfs: fix two memory leaks in xfs_attr_list.c error paths Mateusz Guzik
@ 2016-02-10 20:38 ` Eric Sandeen
2016-02-12 9:27 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2016-02-10 20:38 UTC (permalink / raw)
To: xfs
On 2/10/16 12:35 PM, Mateusz Guzik wrote:
> This plugs 2 trivial leaks in xfs_attr_shortform_list and
> xfs_attr3_leaf_list_int.
>
> Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
> Cc: <stable@vger.kernel.org>
Looks good (tho I wonder why coverity didn't spot...)
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
>
> ---
> fs/xfs/xfs_attr_list.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
> index 0ef7c2e..4fa1482 100644
> --- a/fs/xfs/xfs_attr_list.c
> +++ b/fs/xfs/xfs_attr_list.c
> @@ -202,8 +202,10 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
> sbp->namelen,
> sbp->valuelen,
> &sbp->name[sbp->namelen]);
> - if (error)
> + if (error) {
> + kmem_free(sbuf);
> return error;
> + }
> if (context->seen_enough)
> break;
> cursor->offset++;
> @@ -454,14 +456,13 @@ xfs_attr3_leaf_list_int(
> args.rmtblkcnt = xfs_attr3_rmt_blocks(
> args.dp->i_mount, valuelen);
> retval = xfs_attr_rmtval_get(&args);
> - if (retval)
> - return retval;
> - retval = context->put_listent(context,
> - entry->flags,
> - name_rmt->name,
> - (int)name_rmt->namelen,
> - valuelen,
> - args.value);
> + if (!retval)
> + retval = context->put_listent(context,
> + entry->flags,
> + name_rmt->name,
> + (int)name_rmt->namelen,
> + valuelen,
> + args.value);
> kmem_free(args.value);
> } else {
> retval = context->put_listent(context,
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: fix two memory leaks in xfs_attr_list.c error paths
2016-02-10 18:35 [PATCH] xfs: fix two memory leaks in xfs_attr_list.c error paths Mateusz Guzik
2016-02-10 20:38 ` Eric Sandeen
@ 2016-02-12 9:27 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2016-02-12 9:27 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: stable, xfs
On Wed, Feb 10, 2016 at 07:35:37PM +0100, Mateusz Guzik wrote:
> This plugs 2 trivial leaks in xfs_attr_shortform_list and
> xfs_attr3_leaf_list_int.
Can you please add a out: label before the kmem_free at the end of
the function, return the actual error value there and make all others
returns after the kmem_alloc jump to that label?
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-12 9:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-10 18:35 [PATCH] xfs: fix two memory leaks in xfs_attr_list.c error paths Mateusz Guzik
2016-02-10 20:38 ` Eric Sandeen
2016-02-12 9:27 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox