From patchwork Sun Mar 13 15:02:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingxuan Xiang X-Patchwork-Id: 551017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D510C433F5 for ; Sun, 13 Mar 2022 15:06:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbiCMPHT (ORCPT ); Sun, 13 Mar 2022 11:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiCMPHS (ORCPT ); Sun, 13 Mar 2022 11:07:18 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA2F558E4E; Sun, 13 Mar 2022 08:06:07 -0700 (PDT) Received: from frank-virtual-machine.lan ([172.16.0.254]) (user=mx_xiang@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 22DF4sL0020655-22DF4sL3020655 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Sun, 13 Mar 2022 23:05:09 +0800 From: Mingxuan Xiang To: Jiri Kosina , Benjamin Tissoires , Rafi Rubin Cc: Mingxuan Xiang , Dongliang Mu , Jiri Kosina , 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 Message-Id: <20220313150237.1214062-1-mx_xiang@hust.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-FEAS-AUTH-USER: mx_xiang@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 Fixes: eab32f5f6557 ("HID: ntrig: add sysfs access to filter parameters") Signed-off-by: Mingxuan Xiang --- 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;