Use the number of subdevices allocated (dev->n_subdevices) in the
(*detach) instead of assuming a given number.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfondation.org>
---
 drivers/staging/comedi/drivers/serial2002.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/serial2002.c 
b/drivers/staging/comedi/drivers/serial2002.c
index e3243f8..2250ac6 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -811,7 +811,7 @@ static void serial2002_detach(struct comedi_device *dev)
        struct comedi_subdevice *s;
        int i;
 
-       for (i = 0; i < 5; i++) {
+       for (i = 0; i < dev->n_subdevices; i++) {
                s = &dev->subdevices[i];
                kfree(s->maxdata_list);
                kfree(s->range_table_list);
-- 
1.8.1.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to