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] [thread-next>] [day] [month] [year] [list]
Message-ID: <b47f8f37-fbde-5487-5025-fcb0df7a7e30@redhat.com>
Date:   Wed, 12 Feb 2020 12:21:10 +0100
From:   David Hildenbrand <david@...hat.com>
To:     Yang Shi <yang.shi@...ux.alibaba.com>, akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup
 fails

On 11.02.20 06:24, Yang Shi wrote:
> When kstrndup fails (returns NULL) there is no memory is allocated by
> kmalloc, so no need to call kfree().

"When kstrndup fails, no memory was allocated and we can exit directly."

Reviewed-by: David Hildenbrand <david@...hat.com>

> 
> Signed-off-by: Yang Shi <yang.shi@...ux.alibaba.com>
> ---
>  mm/vmpressure.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/vmpressure.c b/mm/vmpressure.c
> index 4bac22f..0590f00 100644
> --- a/mm/vmpressure.c
> +++ b/mm/vmpressure.c
> @@ -371,10 +371,8 @@ int vmpressure_register_event(struct mem_cgroup *memcg,
>  	int ret = 0;
>  
>  	spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL);
> -	if (!spec) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> +	if (!spec)
> +		return -ENOMEM;
>  
>  	/* Find required level */
>  	token = strsep(&spec, ",");
> 


-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ