Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2671713pxp; Tue, 22 Mar 2022 03:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNS01J7N66k9avFPxBbaPvM/h76BVBKefjQRBWuvyAjXtRLgbNdZAHlTesFdF802Lmi3hx X-Received: by 2002:a17:90b:4ac1:b0:1c6:adfe:322a with SMTP id mh1-20020a17090b4ac100b001c6adfe322amr4279292pjb.189.1647946112317; Tue, 22 Mar 2022 03:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647946112; cv=none; d=google.com; s=arc-20160816; b=r93TGG8p7g49sHY/gunSwAqGQRXdY1ZRPkOWJCv0UqX2CZXMJsPhHXlsFRsQ5I7Mao SJwqi91LeCe09uAInFdRnGk7tBfMNvUvdzisnR1XLhl7Ie+NWH9heaup3uh+8W86RDPR l4nnDXKNuA+Do5yqaflO3Po00in5U872a/k7MebCXhXO6u8nPtVzAcnYNLuAO3SdrmDP 6Q15wQr9U1H0D7p/ih8venhNeJp4+9Dtir3eV8KQPlnIZSBw+XWlPXd78XgHpzUruPlt 0P60KiefJ0hjAhsFsI4nqnTiQWERCUwglkhCZdSb8Smfq/FgtgBzeTpbtpZAIdJs8oWS 4KFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=I6aT75VOl70Kq1WWHD+hdV3JFdz2A17fd3K4+GP4ckY=; b=tMuGP5IS1JmS8Ls69lDmCeUiLEYeHQQFRKaJxhFZDsFfNxKApwIOc9kOXzgtgP+Tl3 AmY+8lq5eBEm3xUecSDUF6zK8r5cK2z0KLLdaZWlCnOtQPjWqhO+mB+iCyWK3jYrNhXs 1pazXQDfnqwDYqqEXAZF4grw2GTSmm8Vdq9R8e5F/glnoiC+oi0ewqIAynHmDvLspPPR rPMDB1qIJlF83kXGrbL2aR3JqImCawNrEJJzKhT2hV4KKi/rPGOH5QNvk6k4cleHtzhS TbHtyfYXxgy07jIbv3xwene6zqSeDBZxxirBCiZ6VZGpWgHeBw1Ibswm6OnLMkMJenxa zIzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hP85i/2d"; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t14-20020a17090aba8e00b001bd14e01fb5si1780287pjr.163.2022.03.22.03.48.20; Tue, 22 Mar 2022 03:48:32 -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=@linuxfoundation.org header.s=korg header.b="hP85i/2d"; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232177AbiCVJF6 (ORCPT + 99 others); Tue, 22 Mar 2022 05:05:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbiCVJFs (ORCPT ); Tue, 22 Mar 2022 05:05:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FC7046668 for ; Tue, 22 Mar 2022 02:04:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B075361658 for ; Tue, 22 Mar 2022 09:04:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1DE9C340EE; Tue, 22 Mar 2022 09:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647939860; bh=E7kgiCH6KC61WFNUuFqMt1ZzIW1CD6iDp319+kmnUr0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hP85i/2dfhMiZlecOUXNTkuYtTJmi42dvZ5sBLxd9MhpNr5ebuTs3xxFqSSbOI2XQ kPePMBOZFm1lhjfBrITLl0XHuA++/irJ0HnV7qeJ9jiMGNJfnQTvUb1KJn1P6rbhlM q7eDksrHRhkef9lUjALnQ3C4R3686mcDOGgQVMIs= Date: Tue, 22 Mar 2022 09:48:28 +0100 From: Greg Kroah-Hartman To: "Fabio M. De Francesco" Cc: David Kershner , sparmaintainer@unisys.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: unisys: Properly test debugfs_create_dir() return values Message-ID: References: <20220322083858.16887-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220322083858.16887-1-fmdefrancesco@gmail.com> X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Tue, Mar 22, 2022 at 09:38:58AM +0100, Fabio M. De Francesco wrote: > debugfs_create_dir() returns a pointers to a dentry objects. On failures > it returns errors. Currently the values returned to visornic_probe() > seem to be tested for being equal to NULL in case of failures. > > Properly test with "if (IS_ERR())" and then assign the correct error > value to the "err" variable. > > Signed-off-by: Fabio M. De Francesco > --- > drivers/staging/unisys/visornic/visornic_main.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c > index 643432458105..58d03f3d3173 100644 > --- a/drivers/staging/unisys/visornic/visornic_main.c > +++ b/drivers/staging/unisys/visornic/visornic_main.c > @@ -1922,11 +1922,11 @@ static int visornic_probe(struct visor_device *dev) > /* create debug/sysfs directories */ > devdata->eth_debugfs_dir = debugfs_create_dir(netdev->name, > visornic_debugfs_dir); > - if (!devdata->eth_debugfs_dir) { > + if (IS_ERR(devdata->eth_debugfs_dir)) { > dev_err(&dev->device, > "%s debugfs_create_dir %s failed\n", > __func__, netdev->name); > - err = -ENOMEM; > + err = PTR_ERR(devdata->eth_debugfs_dir); > goto cleanup_register_netdev; > } Also, why does this variable have to be saved off at all? It should only be used later when removing the directory, and we can just look it up at that point in time, right? Also, what happens if the network device name changes? thanks, greg k-h