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: <e25baf8f-607c-6aa6-6902-c76b47834e55@huawei.com>
Date:   Thu, 15 Jul 2021 17:21:39 +0800
From:   "Leizhen (ThunderTown)" <thunder.leizhen@...wei.com>
To:     Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-stm32 <linux-stm32@...md-mailman.stormreply.com>,
        linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] stm class: dummy_stm: Fix error return code in
 dummy_stm_init()

Hi all:
  Can someone review it? Although it is unlikely that the OOM will
occur during initialization, this is indeed a coding error.

On 2021/5/8 10:36, Zhen Lei wrote:
> Although 'ret' has been initialized to -ENOMEM, but it will be reassigned
> by the "ret = stm_register_device(...)" statement in the for loop. So
> that, the value of 'ret' is unknown when kasprintf() failed.
> 
> Fixes: bcfdf8afdebe ("stm class: dummy_stm: Create multiple devices")
> Reported-by: Hulk Robot <hulkci@...wei.com>
> Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
> ---
>  drivers/hwtracing/stm/dummy_stm.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/stm/dummy_stm.c b/drivers/hwtracing/stm/dummy_stm.c
> index 38528ffdc0b3..36d32e7afb35 100644
> --- a/drivers/hwtracing/stm/dummy_stm.c
> +++ b/drivers/hwtracing/stm/dummy_stm.c
> @@ -68,7 +68,7 @@ static int dummy_stm_link(struct stm_data *data, unsigned int master,
>  
>  static int dummy_stm_init(void)
>  {
> -	int i, ret = -ENOMEM;
> +	int i, ret;
>  
>  	if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX)
>  		return -EINVAL;
> @@ -80,8 +80,10 @@ static int dummy_stm_init(void)
>  
>  	for (i = 0; i < nr_dummies; i++) {
>  		dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i);
> -		if (!dummy_stm[i].name)
> +		if (!dummy_stm[i].name) {
> +			ret = -ENOMEM;
>  			goto fail_unregister;
> +		}
>  
>  		dummy_stm[i].sw_start		= master_min;
>  		dummy_stm[i].sw_end		= master_max;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ