Commit a437dee5 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: serial2002: fix Coverity "Explicit null dereference"

serial2002_setup_subdevices() initializes each subdevice based on the
config read from the attached serial device. Part of this initialization
is to setup the subdevice range_table_list for the non digital subdevices.
The range_table_list is allocated only when a 'range' is passed to the
functions. Each channel of the subdevice then has it's 'range' initialized
and that range is added to the range_table_list.

The logic of this function works but causes Coverity complain about an
Explicit null dereference of the allocated 'range_table_list'. Add a check
for the 'range_table_list' to quiet the Coverity issue.

Reported-by: coverity (CID 1011632)
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent accb298f
...@@ -373,7 +373,7 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s, ...@@ -373,7 +373,7 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s,
if (cfg[j].kind == kind) { if (cfg[j].kind == kind) {
if (mapping) if (mapping)
mapping[chan] = j; mapping[chan] = j;
if (range) { if (range && range_table_list) {
range[j].length = 1; range[j].length = 1;
range[j].range.min = cfg[j].min; range[j].range.min = cfg[j].min;
range[j].range.max = cfg[j].max; range[j].range.max = cfg[j].max;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment