staging: comedi: serial2002: fix Coverity "Explicit null dereference"
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 20 Apr 2015 18:49:06 +0000 (11:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Apr 2015 15:15:59 +0000 (17:15 +0200)
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/serial2002.c

index 304ebff119eeac1cd83a70cd318b5957b2135f11..83da162deb526c0a790efba41b23ff4784e563b8 100644 (file)
@@ -373,7 +373,7 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s,
                if (cfg[j].kind == kind) {
                        if (mapping)
                                mapping[chan] = j;
-                       if (range) {
+                       if (range && range_table_list) {
                                range[j].length = 1;
                                range[j].range.min = cfg[j].min;
                                range[j].range.max = cfg[j].max;