[lvc-project] [PATCH v2] comedi: adl_pci9111: Fix possible division by zero in pci9111_ai_do_cmd_test()
Aleksandr Mishin
amishin at t-argos.ru
Wed Sep 18 15:53:38 MSK 2024
Division by zero is possible in pci9111_ai_do_cmd_test() in case of scan
begin trigger source is TRIG_TIMER and 'chanlist_len' is zero.
Add zero value check to prevent division by zero.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: f1c51faabc4d ("staging: comedi: adl_pci9111: tidy up (*do_cmdtest) Step 4")
Suggested-by: Ian Abbott <abbotti at mev.co.uk>
Reviewed-by: Ian Abbott <abbotti at mev.co.uk>
Signed-off-by: Aleksandr Mishin <amishin at t-argos.ru>
---
v1->v2: Update comment and fix as suggested by Ian,
add "Reviewed-by: Ian Abbott <abbotti at mev.co.uk>"
(https://lore.kernel.org/all/4f46343a-a1f9-4082-8ef2-50cdb3d74f31@mev.co.uk/)
drivers/comedi/drivers/adl_pci9111.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/comedi/drivers/adl_pci9111.c b/drivers/comedi/drivers/adl_pci9111.c
index 086d93f40cb9..e5989d180650 100644
--- a/drivers/comedi/drivers/adl_pci9111.c
+++ b/drivers/comedi/drivers/adl_pci9111.c
@@ -310,7 +310,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
* There's only one timer on this card, so the scan_begin timer
* must be a multiple of chanlist_len*convert_arg
*/
- if (cmd->scan_begin_src == TRIG_TIMER) {
+ if (cmd->scan_begin_src == TRIG_TIMER && cmd->chanlist_len) {
arg = cmd->chanlist_len * cmd->convert_arg;
if (arg < cmd->scan_begin_arg)
--
2.30.2
More information about the lvc-project
mailing list