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
> 

Reply via email to