On Mon, Aug 11, 2014 at 03:09:35AM +0100, Filipe Manana wrote:
> + if (name_len + data_len > buf_len) {
> + buf_len = name_len + data_len;
> + if (is_vmalloc_addr(buf)) {
> + vfree(buf);
> + buf = NULL;
> + } else {
> + char *tmp = krealloc(buf, buf_len, GFP_NOFS);
This could fail with a warning (high order allocation) so I suggest to
add __GFP_NOWARN, the vmalloc fallback will catch fragmented memory case
and fail if theres no memory.
> +
> + if (!tmp)
> + kfree(buf);
> + buf = tmp;
> + }
> + if (!buf) {
> + buf = vmalloc(buf_len);
> + if (!buf) {
> + ret = -ENOMEM;
> + goto out;
> + }
> + }
> + }
> +
> read_extent_buffer(eb, buf, (unsigned long)(di + 1),
> name_len + data_len);
>
> @@ -1071,7 +1094,10 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
> }
>
> out:
> - kfree(buf);
> + if (is_vmalloc_addr(buf))
> + vfree(buf);
> + else
> + kfree(buf);
There's even kvfree to do this.
> return ret;
> }
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html