Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

UWB: Return UWB_RSV_ALLOC_NOT_FOUND rather than crashing on NULL dereference if kzalloc fails

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().

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Jesper Juhl and committed by
Greg Kroah-Hartman
793b6233 886ccd45

+2 -1
+2 -1
drivers/uwb/allocator.c
··· 326 326 int bit_index; 327 327 328 328 ai = kzalloc(sizeof(struct uwb_rsv_alloc_info), GFP_KERNEL); 329 - 329 + if (!ai) 330 + return UWB_RSV_ALLOC_NOT_FOUND; 330 331 ai->min_mas = rsv->min_mas; 331 332 ai->max_mas = rsv->max_mas; 332 333 ai->max_interval = rsv->max_interval;