Skip to content

Commit

Permalink
UWB: Return UWB_RSV_ALLOC_NOT_FOUND rather than crashing on NULL dere…
Browse files Browse the repository at this point in the history
…ference 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 <[email protected]>
Acked-by: David Vrabel <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jjuhl authored and gregkh committed Nov 11, 2010
1 parent 886ccd4 commit 793b623
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/uwb/allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 793b623

Please sign in to comment.