lkml.org 
[lkml]   [2007]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [EXT4 set 5][PATCH 1/1] expand inode i_extra_isize to support features in larger inode
    On Jul 16, 2007  16:52 -0700, Mingming Cao wrote:
    > I am not sure why we need GFP_KERNEL flag here. I think we should use
    > GFP_NOFS instead. The following patch use the GFP_NOFS flag, as well as
    > fixing memory leak issue introduced by the ext4 expand inode extra isize
    > patch.
    >
    > Fixing memory allocation issue with expand inode extra isize patch.
    >
    > - use GFP_NOFS instead of GFP_KERNEL flag for memory allocation
    > - use kzalloc instead of kmalloc

    This doesn't need kzalloc() for buffer and b_entry_name, since they are
    immediately overwritten by memcpy().

    > - fix memory leak in the success case, at the end of while loop.
    > goto cleanup;
    > @@ -1302,7 +1302,15 @@ retry:
    > error = ext4_xattr_block_set(handle, inode, &i, bs);
    > if (error)
    > goto cleanup;
    > + kfree(b_entry_name);
    > + kfree(buffer);
    > + brelse(is->iloc.bh);
    > + kfree(is);
    > + kfree(bs);
    > + brelse(bh);
    > }
    > + up_write(&EXT4_I(inode)->xattr_sem);
    > + return 0;
    >
    > cleanup:
    > kfree(b_entry_name);

    I don't think you should have brelse(bh) inside the loop, since it is
    allocated before the loop starts.

    Cheers, Andreas
    --
    Andreas Dilger
    Principal Software Engineer
    Cluster File Systems, Inc.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-07-17 02:09    [W:0.040 / U:29.560 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site