accel/qaic: Use overflow check function instead of division
Subsystems (3)
PATCH 1/1 accel/qaic: Use overflow check function instead of division
From: Carl Vanderlip <[email protected]>
Division is an expensive operation. Overflow check functions exist already. Use existing overflow check functions rather than dividing to check for overflow.
--- drivers/accel/qaic/qaic_control.c | 5 +++-- drivers/accel/qaic/qaic_data.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/accel/qaic/qaic_control.c +3 -2
@@ -655,8 +655,9 @@ static int encode_activate(struct qaic_device *qdev, void *trans, struct wrapperreturn -EINVAL ; nelem = in_trans->queue_size; - size = (get_dbc_req_elem_size () +get_dbc_rsp_elem_size ()) * nelem; -if (size / nelem !=get_dbc_req_elem_size () +get_dbc_rsp_elem_size ()) +if (check_mul_overflow ((u32)(get_dbc_req_elem_size () +get_dbc_rsp_elem_size ()), + nelem, + &size))return -EINVAL ;if (size +QAIC_DBC_Q_GAP +QAIC_DBC_Q_BUF_ALIGN < size)
drivers/accel/qaic/qaic_data.c +3 -2
@@ -953,8 +953,9 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fiif (args->hdr.count ==0 )return -EINVAL ; - arg_size = args->hdr.count *sizeof (*slice_ent); -if (arg_size / args->hdr.count !=sizeof (*slice_ent)) +if (check_mul_overflow ((unsigned long )args->hdr.count, + (unsigned long )sizeof (*slice_ent), + &arg_size))return -EINVAL ;if (!(args->hdr.dir ==DMA_TO_DEVICE || args->hdr.dir ==DMA_FROM_DEVICE ))
Signature · 1 line
2.43.0
Quoted 8 lines · Youssef Samir
From: Carl Vanderlip <[email protected]>
Division is an expensive operation. Overflow check functions exist already. Use existing overflow check functions rather than dividing to check for overflow.
Signed-off-by Carl Vanderlip <[email protected]>Signed-off-by Youssef Samir <[email protected]>
Quoted 9 lines · Youssef Samir
From: Carl Vanderlip <[email protected]>
Division is an expensive operation. Overflow check functions exist already. Use existing overflow check functions rather than dividing to check for overflow.
Signed-off-by Carl Vanderlip <[email protected]>Signed-off-by Youssef Samir <[email protected]>---
Quoted 8 lines · Youssef Samir
From: Carl Vanderlip <[email protected]>
Division is an expensive operation. Overflow check functions exist already. Use existing overflow check functions rather than dividing to check for overflow.
Signed-off-by Carl Vanderlip <[email protected]>Signed-off-by Youssef Samir <[email protected]>
Pushed to drm-misc-next.
-Jeff