From: H Hartley Sweeten Date: Fri, 5 Apr 2013 23:10:01 +0000 (-0700) Subject: staging: comedi: serial2002: don't assume the number of subdevices to detach X-Git-Tag: next-20130422~28^2~220 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fd47579ba065f74bb5f833248ddcdfbb71feddcb;p=karo-tx-linux.git 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 --- 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);