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: <c934c457-fe8f-7937-f348-eccf46375878@suse.de>
Date:   Fri, 8 Apr 2022 00:59:34 +0800
From:   Coly Li <colyli@...e.de>
To:     QintaoShen <unSimple1993@....com>
Cc:     linux-bcache@...r.kernel.org, kent.overstreet@...il.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] bcache: Check for NULL return of kzalloc()

On 3/24/22 5:27 PM, QintaoShen wrote:
> kzalloc() is a memory allocation function which may return a NULL pointer.
> Therefore, it is better to check the return value of kzalloc() to avoid potential
> NULL-pointer dereference.
>
> Signed-off-by: QintaoShen <unSimple1993@....com>
> ---
>   drivers/md/bcache/request.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index fdd0194..232ffe3 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1105,6 +1105,9 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
>   	 * which would call closure_get(&dc->disk.cl)
>   	 */
>   	ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
> +	if (!ddpp)
> +		return ;

This is wrong. If you test your patch, you may experience a system hang 
I guess.


Coly Li


> +
>   	ddip->d = d;
>   	/* Count on the bcache device */
>   	ddip->orig_bdev = orig_bdev;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ