From 789728f7be1e6c7f22380ae739d7b692d2c08d0f Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 17 Jan 2007 13:41:33 -0800 Subject: [PATCH] Check return of calloc() in ibv_get_device_list() Don't blindly copy device pointers if calloc() returns NULL. Signed-off-by: Roland Dreier --- src/device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/device.c b/src/device.c index f7ef224..7f86e1a 100644 --- a/src/device.c +++ b/src/device.c @@ -63,9 +63,13 @@ struct ibv_device **ibv_get_device_list(int *num) num_devices = ibverbs_init(&device_list); l = calloc(num_devices + 1, sizeof (struct ibv_device *)); + if (!l) + goto out; + for (i = 0; i < num_devices; ++i) l[i] = device_list[i]; +out: pthread_mutex_unlock(&device_list_lock); if (num) -- 2.46.0