From: Dan Carpenter <dan.carpenter@oracle.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ian Abbott <abbotti@mev.co.uk>,
linux-staging@lists.linux.dev,
H Hartley Sweeten <hsweeten@visionengravers.com>,
"Spencer E . Olson" <olsonse@umich.edu>
Subject: Re: [PATCH 0/5] staging: comedi: tests: Fix various issues
Date: Wed, 14 Apr 2021 13:09:05 +0300 [thread overview]
Message-ID: <20210414100905.GD6048@kadam> (raw)
In-Reply-To: <YG3rUN0fvyA6HCpf@kroah.com>
I've been saying we should move this code out of staging for years now.
Normally I like to do a final static analysis check before drivers move
out of staging.
This driver is doing a bunch of DMA on stack which doesn't work on
all architectures. You have to use kmalloc() (or vmalloc() I suppose)
memory for DMA.
drivers/staging/comedi/drivers/dt9812.c:249 dt9812_read_info() error: doing dma on the stack (&cmd)
drivers/staging/comedi/drivers/dt9812.c:273 dt9812_read_multiple_registers() error: doing dma on the stack (&cmd)
drivers/staging/comedi/drivers/dt9812.c:299 dt9812_write_multiple_registers() error: doing dma on the stack (&cmd)
drivers/staging/comedi/drivers/dt9812.c:318 dt9812_rmw_multiple_registers() error: doing dma on the stack (&cmd)
drivers/staging/comedi/drivers/dt9812.c:330 dt9812_digital_in() error: doing dma on the stack (value)
drivers/staging/comedi/drivers/dt9812.c:456 dt9812_analog_in() error: doing dma on the stack (val)
drivers/staging/comedi/drivers/dt9812.c:692 dt9812_reset_device() error: doing dma on the stack (&tmp8)
drivers/staging/comedi/drivers/dt9812.c:700 dt9812_reset_device() error: doing dma on the stack (&tmp8)
drivers/staging/comedi/drivers/dt9812.c:711 dt9812_reset_device() error: doing dma on the stack (&tmp16)
drivers/staging/comedi/drivers/dt9812.c:718 dt9812_reset_device() error: doing dma on the stack (&tmp16)
drivers/staging/comedi/drivers/dt9812.c:725 dt9812_reset_device() error: doing dma on the stack (&tmp16)
drivers/staging/comedi/drivers/dt9812.c:732 dt9812_reset_device() error: doing dma on the stack (&tmp32)
The test_ni_get_reg_value() function calls
unittest(ni_get_reg_value_roffs(-1, O(0), T, 1) == -1,
"check bad direct trigger arg for first reg->dest w/offs\n");
The -1 is type promoted to a high positive value so src is greater than
NI_NAMES_BASE. It's not clear that that was intentional.
drivers/staging/comedi/drivers/tests/../ni_routes.h:269 ni_get_reg_value_roffs() warn: 'src' possible negative type promoted to high
drivers/staging/comedi/drivers/ni_routes.c:61 ni_find_route_values() warn: 'device_family' sometimes too small '8,11' size = 30
59 for (i = 0; ni_all_route_values[i]; ++i) {
60 if (memcmp(ni_all_route_values[i]->family, device_family,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61 strnlen(device_family, 30)) == 0) {
^^^^^^^^^^^^^^^^^^^^^^^^^^
This whole memcmp() is very strange. Why not just use:
if (strncmp(ni_all_route_values[i]->family, device_family, 30) == 0)
62 rv = &ni_all_route_values[i]->register_values[0][0];
63 break;
64 }
65 }
There are a couple places where conditions could probably be deleted.
drivers/staging/comedi/drivers/ni_mio_common.c:2363 ni_ai_cmd() warn: we tested 'dev->irq' before and it was 'true'
drivers/staging/comedi/drivers/usbdux.c:1192 usbduxsub_pwm_irq() warn: we tested 'devpriv->pwm_cmd_running' before and it was 'true'
There is some commented out code that might be worth reviewing.
drivers/staging/comedi/drivers/ni_mio_common.c:6306 ni_E_init() warn: odd binop '0x2 & 0x0'
drivers/staging/comedi/drivers/cb_pcidas64.c:2229 use_hw_sample_counter() warn: ignoring unreachable code.
These places are using char for bitwise operations and there is some
sign extension going on.
drivers/staging/comedi/drivers/icp_multi.c:120 icp_multi_ai_insn_read() warn: using signed char for bitops
drivers/staging/comedi/drivers/usbdux.c:1290 usbdux_pwm_pattern() warn: using signed char for bitops
drivers/staging/comedi/drivers/usbdux.c:1292 usbdux_pwm_pattern() warn: using signed char for bitops
Small resource leaks:
drivers/staging/comedi/drivers/ii_pci20kc.c:503 ii20k_attach() warn: 'dev->mmio' not released on lines: 452,457,465,474,483.
drivers/staging/comedi/drivers/ii_pci20kc.c:503 ii20k_attach() warn: 'membase' not released on lines: 441,452,457,465,474,483.
drivers/staging/comedi/drivers/gsc_hpdi.c:672 gsc_hpdi_auto_attach() warn: 'pcidev->irq' not released on lines: 629,641,646,651,655.
drivers/staging/comedi/drivers/addi_apci_2032.c:289 apci2032_auto_attach() warn: 'pcidev->irq' not released on lines: 279.
drivers/staging/comedi/drivers/cb_pcidas.c:1446 cb_pcidas_auto_attach() warn: 'pcidev->irq' not released on lines: 1295,1301,1305,1340,1358,1378,1409,1427.
drivers/staging/comedi/drivers/cb_pcidas64.c:4046 auto_attach() warn: 'pcidev->irq' not released on lines: 4044.
regards,
dan carpenter
next prev parent reply other threads:[~2021-04-14 10:09 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 14:01 [PATCH 0/5] staging: comedi: tests: Fix various issues Ian Abbott
2021-04-07 14:01 ` [PATCH 1/5] staging: comedi: tests: ni_routes_test: Fix compilation error Ian Abbott
2021-04-07 14:01 ` [PATCH 2/5] staging: comedi: tests: ni_routes_test: Put complex values in parentheses Ian Abbott
2021-04-07 14:01 ` [PATCH 3/5] staging: comedi: tests: ni_routes_test: Avoid CamelCase: <RVi> Ian Abbott
2021-04-07 15:23 ` Spencer Olson
2021-04-07 14:01 ` [PATCH 4/5] staging: comedi: tests: ni_routes_test: Lines should not end with a '(' Ian Abbott
2021-04-07 14:01 ` [PATCH 5/5] staging: comedi: tests: Correct unittest_fptr Ian Abbott
2021-04-07 15:10 ` [PATCH 0/5] staging: comedi: tests: Fix various issues Greg Kroah-Hartman
2021-04-07 15:39 ` Ian Abbott
2021-04-07 15:48 ` Spencer Olson
2021-04-07 16:16 ` Ian Abbott
2021-04-07 17:26 ` Greg Kroah-Hartman
2021-04-07 18:20 ` Ian Abbott
2021-04-08 7:27 ` Greg Kroah-Hartman
2021-04-14 10:09 ` Dan Carpenter [this message]
2021-04-14 10:40 ` Ian Abbott
2021-04-14 12:34 ` Ian Abbott
2021-04-14 13:28 ` Dan Carpenter
2021-04-14 13:57 ` Spencer Olson
2021-04-14 17:24 ` Ian Abbott
2021-04-14 14:29 ` Spencer Olson
2021-04-14 17:05 ` Ian Abbott
2021-04-15 9:57 ` Ian Abbott
2021-04-14 12:40 ` Ian Abbott
2021-04-14 13:12 ` Greg Kroah-Hartman
2021-04-14 13:30 ` Dan Carpenter
2021-04-07 15:43 ` Spencer Olson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210414100905.GD6048@kadam \
--to=dan.carpenter@oracle.com \
--cc=abbotti@mev.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-staging@lists.linux.dev \
--cc=olsonse@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.