Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2171567rwd; Sun, 28 May 2023 09:29:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VS77fLCIXcMsNZmg+IAOvgQkrSwoBOkCqExNOVwo6mrmwBUyXxs5xyj9GguqfzpuAvvMr X-Received: by 2002:a05:6a00:2e26:b0:643:4d69:efb8 with SMTP id fc38-20020a056a002e2600b006434d69efb8mr12811798pfb.6.1685291361884; Sun, 28 May 2023 09:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685291361; cv=none; d=google.com; s=arc-20160816; b=qXO/Y8mg6XyrBfoE6XG07W9rmZOVo3R1HYnu7q21YDt4P052f5TC7vef5hybYK3hiL dvRFd+LD24fDqHu/D58ig6WGgVgm9V61bmpTOMrQ15cYxejgDHJ0IHLkMq3RiEU6WZNt gZJdcTKV/X9ApZK8lgWLiD83N2nKaHclOzUxZLxBFuEHQ+imxAJjiOuPYNl8a5fuSDBp yoTvutPMb/HE7S+M1j4+3BMbrSCda8EXvcF61L64LWM+NAU3A3J7iOvr439bRofoNcI6 KcFHN3yKz1JG5O/6MqTf8S2fekgCRp7XEd7RgPqmeUiM51+PTHgdyIbWSDfE2GEiA1gk KFgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YvgNUPTdKFpPQ5giDMpHNmpnkLWBibax0OWyz2QXbcA=; b=viBfLSNzQz80+dIJP2SFH6zqNLZas2RG+Qa2TIsPQlMw2g7b/wSLrdGTdp+80HQgke p3HPFNYACivE/nquaZzoFSovMoFAjbk6m+gNjRUVGqUBUD/9Gqzr5hyJdTOYymBlpEzP kwQ35VEfzcec9/cnEdriHy2JpojNm9C9tpr1k5F7hOOvWN5Q034qtktzrRCsoQ0SgoiO J7sy98IFhtI4Ij7ULBJWvcGETQmNwbWeHHBUZ+P9CGJGEdDACOqzOlV7zxbhAs6g6g00 DUp20u3n7ydc/eDJvOZ1QlJr0s+iZ3vqV8DtFeG8hL+oteFVB/gxedgkB+WX0QXpCSrI GCtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rWNef71e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a633f05000000b0053f3e6ec82bsi6596754pga.774.2023.05.28.09.29.09; Sun, 28 May 2023 09:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rWNef71e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjE1PNH (ORCPT + 99 others); Sun, 28 May 2023 11:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjE1PNG (ORCPT ); Sun, 28 May 2023 11:13:06 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01077A7; Sun, 28 May 2023 08:13:04 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id 6a1803df08f44-6261a8bbe5fso5352646d6.0; Sun, 28 May 2023 08:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685286784; x=1687878784; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YvgNUPTdKFpPQ5giDMpHNmpnkLWBibax0OWyz2QXbcA=; b=rWNef71eljSgJNTpHZZvr/0PITs0py2BIsbJu8tDe1yuH49P/VMQvvrKoBPHerk7Qy XAc9xMfd7SloXxSYHN4hEgsrXMhv8XftqohBfQSCjmqkF7rAuzgxV9go3oawo5IscCtl RoTWqzjnkolv/NxsulfRK+/hdd988kIZ+fkdM6ux5squD9Wp+gxNQMJlmGW0deOST2w0 WNh07oMtoKtuyNTtdVHGZJm4Tku7ME7uqDHVVUe/NeE4t4Gx1aF9taNihL2BzplcM4R+ PZT/gbVMcs+D3lbZyIA50K0c1CG+aVyLvN4GUzlSfNAkK/eaR4YTNak0xJ13bJE12kQP VkIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685286784; x=1687878784; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YvgNUPTdKFpPQ5giDMpHNmpnkLWBibax0OWyz2QXbcA=; b=Pglcl0Ql1sNGoRMtqjrBnjJmXVfzPplGB0OUdimCT5iEs2l1bm9m+A1bgteDAXqLpw JmBL+XPwtIhDAbyKSz/vmE6kJnr2LkkIWrwfCMH2VCcu7eqj1HA8ElUyjgIvp6qzsQdA hYT0yNMP6jpg2FClZ4LB0T6rlROoxwXpmQFzd8GanE7sVSYwVS57JMAL46aGqh6DfJSY 7pVOyDuo9a0nPGATe54FGyBfxgdkVWkmDvZbCC9K8g2aRvoTf2SWfXw+KuBunOyDPnuj vYmMBWu69U41CQ3iJnB6OxFvl0H7HEREILXqcad87ztvPmXRVVE5qVKkzPzESV9NHJP2 ispw== X-Gm-Message-State: AC+VfDyKKk2us2HI6d+zz45hfAAF6U7evyA99ZUSgVdLq7FcHhGfePbs D1V7PwXYxGBR5/lS4BEMrL2y1tsxKJdpad3c1BJt6IK5 X-Received: by 2002:a05:6214:2487:b0:621:83d:3a47 with SMTP id gi7-20020a056214248700b00621083d3a47mr9282949qvb.39.1685286783534; Sun, 28 May 2023 08:13:03 -0700 (PDT) MIME-Version: 1.0 References: <20230524164210.20567-1-osmtendev@gmail.com> <20230526115340.295b1122@sal.lan> In-Reply-To: <20230526115340.295b1122@sal.lan> From: Osama Muhammad Date: Sun, 28 May 2023 20:12:52 +0500 Message-ID: Subject: Re: [PATCH] smsdvb-debugfs.c: Fix error checking for debugfs_create_file To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, After researching more into it I have come to know that the debugfs API will not return null on error but an ERR_PTR. The modern wisdom about it is to ignore the errors returned by the function as stated in the comment above the function debugfs_create_file. > * NOTE: it's expected that most callers should _ignore_ the errors returned >* by this function. Other debugfs functions handle the fact that the "dentry" >* passed to them could be an error and they don't crash in that case. > * Drivers should generally work fine even if debugfs fails to init anyway. Here is the link to comment :- https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451 Considering this, I will send the revision of the patch by removing error checks. Please correct me if there are any concerns with this. Thanks, Osmten On Fri, 26 May 2023 at 15:53, Mauro Carvalho Chehab wrote: > > Em Wed, 24 May 2023 21:42:10 +0500 > Osama Muhammad escreveu: > > > This patch fixes the error checking in smsdvb-debugfs.c in > > debugfs_create_file. The correct way to check if an error occurred > > is using 'IS_ERR_OR_NULL' inline function. > > > > Signed-off-by: Osama Muhammad > > --- > > drivers/media/common/siano/smsdvb-debugfs.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c > > index 8916bb644756..0f8750d7993c 100644 > > --- a/drivers/media/common/siano/smsdvb-debugfs.c > > +++ b/drivers/media/common/siano/smsdvb-debugfs.c > > @@ -469,7 +469,7 @@ int smsdvb_debugfs_create(struct smsdvb_client_t *client) > > > > d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs, > > client, &debugfs_stats_ops); > > - if (!d) { > > + if (IS_ERR_OR_NULL(d)) { > > debugfs_remove(client->debugfs); > > return -ENOMEM; > > if IS_ERR, it is probably better to return PTR_ERR(d). > > So, please change it accordingly, returning -ENOMEM only on NULL, e. g. > something like (untested): > > if (IS_ERR_OR_NULL(d)) { > debugfs_remove(client->debugfs); > if (!d) > return -ENOMEM; > return PTR_ERR(d); > } > > Regards, > Mauro