Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3991464imm; Mon, 11 Jun 2018 05:21:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIJy7e/YS/MElPaHGJ1q5UYDCsfvxWwkYFGxZ+0lXOjYzWFH7aQ7M5Gjv4b1RCyx2OCOpOa X-Received: by 2002:a63:3c07:: with SMTP id j7-v6mr14431373pga.440.1528719682850; Mon, 11 Jun 2018 05:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528719682; cv=none; d=google.com; s=arc-20160816; b=mREM/pcWv3b+3pT1CTEjzAJlQXc/Se++dvwi+g+dGEavVj3DtPgE+QnrqM+cdPioqB yeesTL4TGsWgyhIdwWkB7HmJuwLqsLLGVCdVZran/7E3Z6YsxjfpVS8jTCfsfWE2X/CD X9VgR5TVODGPAAMww+LEJd60+Fv7ListVe1IjbyBzl6uw2NvFtFSJivFXknVbS/kvbNa uIdYnDTewmIa5VXXL0chgN372Go7eVa5RHc7whapljthJJ1m7bw36gNXssim9lx3+zpt N0Zbuchmyt3o2vcmIQiQFTqC9pFN+ZnkWZd85MCBMkgPsXOMmBUNyYZkTjx5Z94MRIYF 4J0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=XvGxuBZ5y4RxXYiW5XcZtVsMuWV58Sqd1usje1fpbpw=; b=Ctjo8+OAN2vT49j0pSoNnZnAUy2ho8dgw1ibrVHaO76lT+iWdGdS1kTNv4kIb6xOql smRjCrmMaG12D6MEd1CdTW256pzA8Yf6WRVV8HUg3oZIp4fA72jqy0vdnF+oB5xzqR+7 fs/yyhkiHvM4BgHpGA6RF40Ftgf7A3KFppgeyrAXIST5jdr8o6nO/6Ka+tJbU7HHbX8e HaPSbMKZEnGIejgf7kpTByVN/MbdlWcsrBqQw6qT1rsKii+jIfv7Av1AkbQfgyH8aAKN dhX5K1om+J1hzcdrt7K5+g7IjOfcKldBjeaQohmNmxKZLxA94+TDPu+0gbc7UbwX9LxV Jz2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6-v6si6683186pgp.155.2018.06.11.05.21.08; Mon, 11 Jun 2018 05:21:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754209AbeFKMUd (ORCPT + 99 others); Mon, 11 Jun 2018 08:20:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:44399 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754010AbeFKMUc (ORCPT ); Mon, 11 Jun 2018 08:20:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 481AAAED0; Mon, 11 Jun 2018 12:20:31 +0000 (UTC) Date: Mon, 11 Jun 2018 14:20:30 +0200 (CEST) From: Jiri Kosina To: Zhouyang Jia cc: Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: hid-ntrig: add error handling for sysfs_create_group In-Reply-To: <1528707296-35785-1-git-send-email-jiazhouyang09@gmail.com> Message-ID: References: <1528707296-35785-1-git-send-email-jiazhouyang09@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Jun 2018, Zhouyang Jia wrote: > When sysfs_create_group fails, the lack of error-handling code may > cause unexpected results. > > This patch adds error-handling code after calling sysfs_create_group. > > Signed-off-by: Zhouyang Jia > --- > drivers/hid/hid-ntrig.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c > index 43b1c72..1e70dae 100644 > --- a/drivers/hid/hid-ntrig.c > +++ b/drivers/hid/hid-ntrig.c > @@ -955,6 +955,10 @@ 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) { > + hid_err(hdev, "cannot create sysfs group\n"); > + goto err_free; > + } Is it really necessarily to bail out completely here and render the device dysfunctional? Issuing a warning about sysfs knobs being unavailable might be more appropriate. Thanks, -- Jiri Kosina SUSE Labs