All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mingxuan Xiang <mx_xiang@hust.edu.cn>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Rafi Rubin <rafi@seas.upenn.edu>
Cc: Mingxuan Xiang <mx_xiang@hust.edu.cn>,
	Dongliang Mu <dzm91@hust.edu.cn>, Jiri Kosina <jkosina@suse.cz>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] HID: hid-ntrig: fix the error handling code in ntrig_probe
Date: Sun, 13 Mar 2022 23:02:37 +0800	[thread overview]
Message-ID: <20220313150237.1214062-1-mx_xiang@hust.edu.cn> (raw)

If sysfs_create_group in ntrig_probe fails, sysfs_remove_group in
ntrig_remove would hit WARN().

Fix this by returning err in ntrig_probe rather than ignoring the
failure of sysfs_create_group.

CC: Dongliang Mu <dzm91@hust.edu.cn>
Fixes: eab32f5f6557 ("HID: ntrig: add sysfs access to filter parameters")
Signed-off-by: Mingxuan Xiang <mx_xiang@hust.edu.cn>
---
 drivers/hid/hid-ntrig.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index b5d26f03fe6b..f49427815d98 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -951,10 +951,14 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	ret = sysfs_create_group(&hdev->dev.kobj,
 			&ntrig_attribute_group);
-	if (ret)
+	if (ret) {
 		hid_err(hdev, "cannot create sysfs group\n");
+		goto err_sysfs_create;
+	}
 
 	return 0;
+err_sysfs_create:
+	hid_hw_stop(hdev);
 err_free:
 	kfree(nd);
 	return ret;
-- 
2.25.1


             reply	other threads:[~2022-03-13 15:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-13 15:02 Mingxuan Xiang [this message]
2022-03-30 15:25 ` [PATCH] HID: hid-ntrig: fix the error handling code in ntrig_probe Jiri Kosina
2022-04-03 18:34   ` Rafi Rubin

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=20220313150237.1214062-1-mx_xiang@hust.edu.cn \
    --to=mx_xiang@hust.edu.cn \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dzm91@hust.edu.cn \
    --cc=jikos@kernel.org \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafi@seas.upenn.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.