- __u32 *new;
- int new_size;
-
- LASSERT(min_count != 0);
-
- if (op->op_count < op->op_size)
- return 0;
-
- new_size = max(min_count, 2 * op->op_size);
- OBD_ALLOC(new, new_size * sizeof(op->op_array[0]));
- if (new == NULL)
- return -ENOMEM;
-
- /* copy old array to new one */
- memcpy(new, op->op_array, op->op_size * sizeof(op->op_array[0]));
- OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
- op->op_array = new;
- op->op_size = new_size;
- return 0;
+ __u32 *new;
+ __u32 new_size;
+
+ LASSERT(min_count != 0);
+
+ if (op->op_count * sizeof(op->op_array[0]) < op->op_size)
+ return 0;
+
+ new_size = max_t(__u32, min_count * sizeof(op->op_array[0]),
+ 2 * op->op_size);
+ OBD_ALLOC(new, new_size);
+ if (new == NULL)
+ return -ENOMEM;
+
+ /* copy old array to new one */
+ memcpy(new, op->op_array, op->op_size);
+ OBD_FREE(op->op_array, op->op_size);
+ op->op_array = new;
+ op->op_size = new_size;
+ return 0;