lkml.org 
[lkml]   [2020]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] nvmem: core: fix possibly memleak when use nvmem_cell_info_to_nvmem_cell()
On Wed, Sep 23, 2020 at 02:50:05AM +0300, Vadym Kochan wrote:
[CUT]
>
> +static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
> + const struct nvmem_cell_info *info,
> + struct nvmem_cell *cell)
> +{
> + int err;
> +
> + err = __nvmem_cell_info_to_nvmem_cell(nvmem, info, cell);
> + if (err)
> + return err;
> +
> + cell->name = kstrdup_const(info->name, GFP_KERNEL);
> + if (!cell->name)
> + return -ENOMEM;
> +
> + return 0;
> +}
> +
> /**
> * nvmem_add_cells() - Add cell information to an nvmem device
> *
> @@ -418,6 +434,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem,
>
> rval = nvmem_cell_info_to_nvmem_cell(nvmem, &info[i], cells[i]);
> if (rval) {
> + kfree_const(cells[i]->name);
Sorry, looks like this should not happen with new changes.

> kfree(cells[i]);
> goto err;
> }
> @@ -1460,7 +1477,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
> if (!nvmem)
> return -EINVAL;
>
> - rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
> + rc = __nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
> if (rc)
> return rc;
>
> @@ -1490,7 +1507,7 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem,
> if (!nvmem)
> return -EINVAL;
>
> - rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
> + rc = __nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
> if (rc)
> return rc;
>
> --
> 2.17.1
>

\
 
 \ /
  Last update: 2020-09-23 09:16    [W:0.031 / U:1.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site