Skip to contentSkip to conversation

Input: elo - fix an error code in elo_connect()

PATCH In review Dan Carpenter 2 participants 3 messages Jan 28, 2021 – Feb 17, 2021

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

PATCH 1/1 Input: elo - fix an error code in elo_connect()

If elo_setup_10() fails then this should return an error code instead of success.

Fixes fae3006e4b42 ("Input: elo - add support for non-pressure-sensitive touchscreens")
---
 drivers/input/touchscreen/elo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/elo.c +3 -1
index e0bacd34866a..4b2fb73da5e2 100644
@@ -341,8 +341,10 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
 	switch (elo->id) {
 
 	case 0: /* 10-byte protocol */
-		if (elo_setup_10(elo))
+		if (elo_setup_10(elo)) {
+			err = -EINVAL;
 			goto fail3;
+		}
 
 		break;
 
Signature · 1 line
2.29.2
maintainer
#1 lore raw

Hi Dan,

Quoted 2 lines · Dan Carpenter

If elo_setup_10() fails then this should return an error code instead of success.

Thank you for the patch.

Quoted 12 lines
Fixes fae3006e4b42 ("Input: elo - add support for non-pressure-sensitive touchscreens")
---
 drivers/input/touchscreen/elo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/elo.c +0 -0
index e0bacd34866a..4b2fb73da5e2 100644

drivers/input/touchscreen/elo.c static int elo_connect(struct serio *serio, struct serio_driver *drv) · line 345

Quoted 6 lines
drivers/input/touchscreen/elo.c +2 -1
@@ -341,8 +341,10 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
 	switch (elo->id) {
 
 	case 0: /* 10-byte protocol */
-		if (elo_setup_10(elo))
+		if (elo_setup_10(elo)) {
+			err = -EINVAL;

Ideally we'd propagate error from elo_setup_10() and underlying code, but we are not ready for it, as most serio code simply uses -1 for errors. However I think that -EIO would suit better here. Please let me know if you disagree, otherwise I'll fix it up on my side.

Thanks!

Quoted 8 lines
drivers/input/touchscreen/elo.c +1 -0
 			goto fail3;
+		}
 
 		break;
 
Signature · 1 line
2.29.2
Signature · 1 line
Dmitry
#2 lore raw
Quoted 22 lines · Dmitry Torokhov

Hi Dan,

Quoted 2 lines · Dan Carpenter

If elo_setup_10() fails then this should return an error code instead of success.

Thank you for the patch.

Quoted 14 lines
Fixes fae3006e4b42 ("Input: elo - add support for non-pressure-sensitive touchscreens")
---
 drivers/input/touchscreen/elo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/elo.c +0 -0
index e0bacd34866a..4b2fb73da5e2 100644
@@ -341,8 +341,10 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv)
 	switch (elo->id) {
 
Quoted 10 lines

drivers/input/touchscreen/elo.c static int elo_connect(struct serio *serio, struct serio_driver *drv) · line 345

Quoted 4 lines
drivers/input/touchscreen/elo.c +2 -1
 	case 0: /* 10-byte protocol */
-		if (elo_setup_10(elo))
+		if (elo_setup_10(elo)) {
+			err = -EINVAL;

Ideally we'd propagate error from elo_setup_10() and underlying code, but we are not ready for it, as most serio code simply uses -1 for errors. However I think that -EIO would suit better here. Please let me know if you disagree, otherwise I'll fix it up on my side.

-EIO is fine. Thanks!

regards,
dan carpenter