Thread (7 messages) flat view 7 messages, 2 authors, 2017-11-03
STALE3230d

[PATCH 5/5] Input: ad7897 - use separate error handling for different allocators

From: Andi Shyti <hidden>
Date: 2017-11-02 15:38:16
Also in: lkml
Subsystem: ad7877 touchscreen driver, input (keyboard, mouse, joystick, touchscreen) drivers, the rest · Maintainers: Michael Hennerich, Dmitry Torokhov, Linus Torvalds

Split the error between devm_kzalloc and
devm_input_allocate_device, there is no need to call the second
allocator if the first has failed. Besides this doesn't provide
practical advantages.

CC: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Andi Shyti <redacted>
---
 drivers/input/touchscreen/ad7877.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index c8a143db8681..dc2cb99dc43d 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -708,6 +708,9 @@ static int ad7877_probe(struct spi_device *spi)
 	}
 
 	ts = devm_kzalloc(&spi->dev, sizeof(struct ad7877), GFP_KERNEL);
+	if (!ts)
+		return -ENOMEM;
+
 	input_dev = devm_input_allocate_device(&spi->dev);
 	if (!input_dev)
 		return -ENOMEM;
-- 
2.15.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help