From: Vadym Kochan <vadym.kochan@plvision.eu>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvmem: core: fix possibly memleak when use nvmem_cell_info_to_nvmem_cell()
Date: Wed, 23 Sep 2020 10:15:36 +0300 [thread overview]
Message-ID: <20200923071536.GA25173@plvision.eu> (raw)
In-Reply-To: <20200922235005.24371-1-vadym.kochan@plvision.eu>
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
>
prev parent reply other threads:[~2020-09-23 7:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 23:50 [PATCH] nvmem: core: fix possibly memleak when use nvmem_cell_info_to_nvmem_cell() Vadym Kochan
2020-09-23 7:15 ` Vadym Kochan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200923071536.GA25173@plvision.eu \
--to=vadym.kochan@plvision.eu \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox