From fd47579ba065f74bb5f833248ddcdfbb71feddcb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 5 Apr 2013 16:10:01 -0700 Subject: [PATCH] staging: comedi: serial2002: don't assume the number of subdevices to detach Use the number of subdevices allocated (dev->n_subdevices) in the (*detach) instead of assuming a given number. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- 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 e3243f802420..2250ac6da8e4 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); -- 2.39.5