linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hanno Zulla <abos@hanno.de>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] HID: hid-bigbenff: call hid_hw_stop() in case of error
Date: Mon, 17 Feb 2020 16:26:43 +0100	[thread overview]
Message-ID: <1c355bbe-c0fb-395c-9050-346f87eb324c@hanno.de> (raw)
In-Reply-To: <798ec119-ce24-e1e3-17c9-b6018b04d75f@hanno.de>

[PATCH 2/3] HID: hid-bigbenff: call hid_hw_stop() in case of error

It's required to call hid_hw_stop() once hid_hw_start() was called
previously, so error cases need to handle this. Also, hid_hw_close() is
not necessary during removal.

Signed-off-by: Hanno Zulla <kontakt@hanno.de>
---
 drivers/hid/hid-bigbenff.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-bigbenff.c b/drivers/hid/hid-bigbenff.c
index f7e85bacb688..f8c552b64a89 100644
--- a/drivers/hid/hid-bigbenff.c
+++ b/drivers/hid/hid-bigbenff.c
@@ -305,7 +305,6 @@ static void bigben_remove(struct hid_device *hid)
 	struct bigben_device *bigben = hid_get_drvdata(hid);
 
 	cancel_work_sync(&bigben->worker);
-	hid_hw_close(hid);
 	hid_hw_stop(hid);
 }
 
@@ -350,7 +349,7 @@ static int bigben_probe(struct hid_device *hid,
 	error = input_ff_create_memless(hidinput->input, NULL,
 		hid_bigben_play_effect);
 	if (error)
-		return error;
+		goto error_hw_stop;
 
 	name_sz = strlen(dev_name(&hid->dev)) + strlen(":red:bigben#") + 1;
 
@@ -360,8 +359,10 @@ static int bigben_probe(struct hid_device *hid,
 			sizeof(struct led_classdev) + name_sz,
 			GFP_KERNEL
 		);
-		if (!led)
-			return -ENOMEM;
+		if (!led) {
+			error = -ENOMEM;
+			goto error_hw_stop;
+		}
 		name = (void *)(&led[1]);
 		snprintf(name, name_sz,
 			"%s:red:bigben%d",
@@ -375,7 +376,7 @@ static int bigben_probe(struct hid_device *hid,
 		bigben->leds[n] = led;
 		error = devm_led_classdev_register(&hid->dev, led);
 		if (error)
-			return error;
+			goto error_hw_stop;
 	}
 
 	/* initial state: LED1 is on, no rumble effect */
@@ -389,6 +390,10 @@ static int bigben_probe(struct hid_device *hid,
 	hid_info(hid, "LED and force feedback support for BigBen gamepad\n");
 
 	return 0;
+
+error_hw_stop:
+	hid_hw_stop(hid);
+	return error;
 }
 
 static __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc,
-- 
2.20.1


  reply	other threads:[~2020-02-17 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 15:24 [PATCH 0/3] HID: hid-bigbenff: fixing three crash bugs in a gamepad driver Hanno Zulla
2020-02-17 15:25 ` [PATCH 1/3] HID: hid-bigbenff: fix general protection fault caused by double kfree Hanno Zulla
2020-02-17 15:26   ` Hanno Zulla [this message]
2020-02-17 15:27     ` [PATCH 3/3] HID: hid-bigbenff: fix race condition for scheduled work during removal Hanno Zulla
2020-02-18 10:40 ` [PATCH 0/3] HID: hid-bigbenff: fixing three crash bugs in a gamepad driver Benjamin Tissoires
2020-02-18 11:30   ` [PATCH v2 " Hanno Zulla
2020-02-18 11:37     ` [PATCH v2 1/3] HID: hid-bigbenff: fix general protection fault caused by double kfree Hanno Zulla
2020-02-18 11:38       ` [PATCH v2 2/3] HID: hid-bigbenff: call hid_hw_stop() in case of error Hanno Zulla
2020-02-18 11:39         ` [PATCH v2 3/3] HID: hid-bigbenff: fix race condition for scheduled work during removal Hanno Zulla
2020-02-19  7:54     ` [PATCH v2 0/3] HID: hid-bigbenff: fixing three crash bugs in a gamepad driver Benjamin Tissoires

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c355bbe-c0fb-395c-9050-346f87eb324c@hanno.de \
    --to=abos@hanno.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).