aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Bartke <andre.bartke@googlemail.com>2011-06-01 18:21:45 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-07 15:28:43 -0400
commit53aebb5312c797e4b63fb50473a55ed054b3cb2f (patch)
treef108a02c9b34e8abe10301fc1dd00ef9bcf069cd
parent0d422f4237ce515678ebbb8781881e5d2e58b9d4 (diff)
staging: iio: error case memory leak fix
The data pointer should be freed in the error cases of adis16400_trigger_handler(). Signed-off-by: Andre Bartke <andre.bartke@gmail.com> Acked-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/iio/imu/adis16400_ring.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c
index 2589a7e167e4..3612373ddede 100644
--- a/drivers/staging/iio/imu/adis16400_ring.c
+++ b/drivers/staging/iio/imu/adis16400_ring.c
@@ -137,13 +137,13 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
137 if (st->variant->flags & ADIS16400_NO_BURST) { 137 if (st->variant->flags & ADIS16400_NO_BURST) {
138 ret = adis16350_spi_read_all(&indio_dev->dev, st->rx); 138 ret = adis16350_spi_read_all(&indio_dev->dev, st->rx);
139 if (ret < 0) 139 if (ret < 0)
140 return ret; 140 goto err;
141 for (; i < ring->scan_count; i++) 141 for (; i < ring->scan_count; i++)
142 data[i] = *(s16 *)(st->rx + i*2); 142 data[i] = *(s16 *)(st->rx + i*2);
143 } else { 143 } else {
144 ret = adis16400_spi_read_burst(&indio_dev->dev, st->rx); 144 ret = adis16400_spi_read_burst(&indio_dev->dev, st->rx);
145 if (ret < 0) 145 if (ret < 0)
146 return ret; 146 goto err;
147 for (; i < indio_dev->ring->scan_count; i++) { 147 for (; i < indio_dev->ring->scan_count; i++) {
148 j = __ffs(mask); 148 j = __ffs(mask);
149 mask &= ~(1 << j); 149 mask &= ~(1 << j);
@@ -158,9 +158,13 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
158 ring->access->store_to(indio_dev->ring, (u8 *) data, pf->timestamp); 158 ring->access->store_to(indio_dev->ring, (u8 *) data, pf->timestamp);
159 159
160 iio_trigger_notify_done(indio_dev->trig); 160 iio_trigger_notify_done(indio_dev->trig);
161 kfree(data);
162 161
162 kfree(data);
163 return IRQ_HANDLED; 163 return IRQ_HANDLED;
164
165err:
166 kfree(data);
167 return ret;
164} 168}
165 169
166void adis16400_unconfigure_ring(struct iio_dev *indio_dev) 170void adis16400_unconfigure_ring(struct iio_dev *indio_dev)