RDMA/core: Use size_{add,sub,mul}() in calls to struct_size()
[linux-2.6-block.git] / drivers / infiniband / core / user_mad.c
index 7e5c33aad1619ddcc4c3d8f6994425330b4586d9..f5feca7fa9b9c9d8473b129c2874eb59b3ff05b3 100644 (file)
@@ -1378,7 +1378,9 @@ static int ib_umad_add_one(struct ib_device *device)
        s = rdma_start_port(device);
        e = rdma_end_port(device);
 
-       umad_dev = kzalloc(struct_size(umad_dev, ports, e - s + 1), GFP_KERNEL);
+       umad_dev = kzalloc(struct_size(umad_dev, ports,
+                                      size_add(size_sub(e, s), 1)),
+                          GFP_KERNEL);
        if (!umad_dev)
                return -ENOMEM;