linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hid: thingm: reorder calls in thingm_probe
@ 2016-03-01 20:24 Heiner Kallweit
  2016-03-10  9:37 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2016-03-01 20:24 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Jiri Kosina, Jacek Anaszewski, linux-input, linux-leds

Based on a suggestion from Benjamin move hid_hw_start() after
thingm_version() to avoid potential races.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/hid/hid-thingm.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/hid/hid-thingm.c b/drivers/hid/hid-thingm.c
index f4196ac..847a497 100644
--- a/drivers/hid/hid-thingm.c
+++ b/drivers/hid/hid-thingm.c
@@ -216,17 +216,13 @@ static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	err = hid_parse(hdev);
 	if (err)
-		goto error;
-
-	err = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
-	if (err)
-		goto error;
+		return err;
 
 	mutex_init(&tdev->lock);
 
 	err = thingm_version(tdev);
 	if (err)
-		goto stop;
+		return err;
 
 	hid_dbg(hdev, "firmware version: %c.%c\n",
 			tdev->version.major, tdev->version.minor);
@@ -237,17 +233,18 @@ static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	if (!tdev->fwinfo) {
 		hid_err(hdev, "unsupported firmware %c\n", tdev->version.major);
-		err = -ENODEV;
-		goto stop;
+		return -ENODEV;
 	}
 
 	tdev->rgb = devm_kzalloc(&hdev->dev,
 			sizeof(struct thingm_rgb) * tdev->fwinfo->numrgb,
 			GFP_KERNEL);
-	if (!tdev->rgb) {
-		err = -ENOMEM;
-		goto stop;
-	}
+	if (!tdev->rgb)
+		return -ENOMEM;
+
+	err = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
+	if (err)
+		return err;
 
 	for (i = 0; i < tdev->fwinfo->numrgb; ++i) {
 		struct thingm_rgb *rgb = tdev->rgb + i;
@@ -255,15 +252,13 @@ static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		rgb->tdev = tdev;
 		rgb->num = tdev->fwinfo->first + i;
 		err = thingm_init_rgb(rgb);
-		if (err)
-			goto stop;
+		if (err) {
+			hid_hw_stop(hdev);
+			return err;
+		}
 	}
 
 	return 0;
-stop:
-	hid_hw_stop(hdev);
-error:
-	return err;
 }
 
 static const struct hid_device_id thingm_table[] = {
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hid: thingm: reorder calls in thingm_probe
  2016-03-01 20:24 [PATCH] hid: thingm: reorder calls in thingm_probe Heiner Kallweit
@ 2016-03-10  9:37 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2016-03-10  9:37 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Benjamin Tissoires, Jacek Anaszewski, linux-input, linux-leds

On Tue, 1 Mar 2016, Heiner Kallweit wrote:

> Based on a suggestion from Benjamin move hid_hw_start() after
> thingm_version() to avoid potential races.

Please make the changelog much more verbose. Namely please describe the 
exact problems this patch is fixing (IOW why we'd want this patch in the 
first place).

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-10  9:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 20:24 [PATCH] hid: thingm: reorder calls in thingm_probe Heiner Kallweit
2016-03-10  9:37 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).