Skip to contentSkip to conversation

iio: test for failed allocation

PATCH In review Dan Carpenter 2 participants 2 messages Mar 16, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: test for failed allocation

We should return test to see if iio_allocate_trigger() fails and return -ENOMEM.

drivers/staging/iio/accel/lis3l02dq_ring.c +3 -0
index a6b7c72..db3270f 100644
@@ -492,6 +492,9 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
 	struct lis3l02dq_state *state = indio_dev->dev_data;
 
 	state->trig = iio_allocate_trigger();
+	if (!state->trig)
+		return -ENOMEM;
+
 	state->trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL);
 	if (!state->trig->name) {
 		ret = -ENOMEM;
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dan Carpenter

We should return test to see if iio_allocate_trigger() fails and return -ENOMEM.

Indeed. Another one for the stupid errors pile!

Thanks.

Quoted 16 lines
drivers/staging/iio/accel/lis3l02dq_ring.c +3 -0
index a6b7c72..db3270f 100644
@@ -492,6 +492,9 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
 	struct lis3l02dq_state *state = indio_dev->dev_data;
 
 	state->trig = iio_allocate_trigger();
+	if (!state->trig)
+		return -ENOMEM;
+
 	state->trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL);
 	if (!state->trig->name) {
 		ret = -ENOMEM;