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]
Date:	Mon, 08 Nov 2010 12:43:02 +0000
From:	David Vrabel <david.vrabel@....com>
To:	Jesper Juhl <jj@...osbits.net>
CC:	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	Greg KH <greg@...ah.com>
Subject: Re: [PATCH] UWB: Return UWB_RSV_ALLOC_NOT_FOUND rather than crashing
 on NULL dereference if kzalloc fails

Jesper Juhl wrote:
> Hi,
> 
> Crashing on a null pointer deref is never a nice thing to do. It seems to 
> me that it's better to simply return UWB_RSV_ALLOC_NOT_FOUND if kzalloc() 
> fails in uwb_rsv_find_best_allocation().

This is fine.

struct uwb_rsv_alloc_info is not that large (about 414 bytes I think) so
it could possibly go on the stack and avoid the allocation.

Acked-by: David Vrabel <david.vrabel@....com>

Greg, seeing as I'm not maintaining the UWB subsystem any more do you
want to pick this (and future) UWB patches?

David

> I may be wrong since I have no way to test this (except compile test) and 
> this is unknown code to me, so please review carefully.
> 
> Please CC me on replies.
> 
> 
> Signed-off-by: Jesper Juhl <jj@...osbits.net>
> ---
>  allocator.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/uwb/allocator.c b/drivers/uwb/allocator.c
> index 436e4f7..e45e673 100644
> --- a/drivers/uwb/allocator.c
> +++ b/drivers/uwb/allocator.c
> @@ -326,7 +326,8 @@ int uwb_rsv_find_best_allocation(struct uwb_rsv *rsv, struct uwb_mas_bm *availab
>  	int bit_index;
>  
>  	ai = kzalloc(sizeof(struct uwb_rsv_alloc_info), GFP_KERNEL);
> -	
> +	if (!ai)
> +		return UWB_RSV_ALLOC_NOT_FOUND;
>  	ai->min_mas = rsv->min_mas;
>  	ai->max_mas = rsv->max_mas;
>  	ai->max_interval = rsv->max_interval;
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ                 http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ