[lvc-project] [PATCH] comedi: adl_pci9111: Fix possible division by zero in pci9111_ai_do_cmd_test()
Aleksandr Mishin
amishin at t-argos.ru
Wed Sep 18 13:43:04 MSK 2024
Division by zero is possible in pci9111_ai_do_cmd_test() in case of scan
begin trigger source is TRIG_TIMER and either 'chanlist_len' or
'convert_arg' 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")
Signed-off-by: Aleksandr Mishin <amishin at t-argos.ru>
---
drivers/comedi/drivers/adl_pci9111.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/comedi/drivers/adl_pci9111.c b/drivers/comedi/drivers/adl_pci9111.c
index 086d93f40cb9..ec1fb570b98c 100644
--- a/drivers/comedi/drivers/adl_pci9111.c
+++ b/drivers/comedi/drivers/adl_pci9111.c
@@ -312,6 +312,8 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
*/
if (cmd->scan_begin_src == TRIG_TIMER) {
arg = cmd->chanlist_len * cmd->convert_arg;
+ if (!arg)
+ return 4;
if (arg < cmd->scan_begin_arg)
arg *= (cmd->scan_begin_arg / arg);
--
2.30.2
More information about the lvc-project
mailing list