aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2007-01-17 13:41:33 -0800
committerRoland Dreier <rolandd@cisco.com>2007-01-17 13:45:05 -0800
commit596803fbae8ff5e2e50b5a99b3e84ee6b3603779 (patch)
tree421ba9cea97ea3b57e8ed3a9622d6992ce80ddd4
parent14b5ee0a4ecdb63222554d3bd31174d0ddbd2c0d (diff)
downloadlibibverbs-596803fbae8ff5e2e50b5a99b3e84ee6b3603779.tar.gz
Check return of calloc() in ibv_get_device_list()
Don't blindly copy device pointers if calloc() returns NULL. Signed-off-by: Roland Dreier <rolandd@cisco.com> (cherry picked from commit 789728f7be1e6c7f22380ae739d7b692d2c08d0f)
-rw-r--r--src/device.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 90e3b15..30c81ba 100644
--- a/src/device.c
+++ b/src/device.c
@@ -62,9 +62,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)