lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200923071536.GA25173@plvision.eu>
Date:   Wed, 23 Sep 2020 10:15:36 +0300
From:   Vadym Kochan <vadym.kochan@...ision.eu>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ