lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZT_MKDVkqMECiv4I@orome.fritz.box>
Date:   Mon, 30 Oct 2023 16:30:48 +0100
From:   Thierry Reding <thierry.reding@...il.com>
To:     Baolu Lu <baolu.lu@...ux.intel.com>
Cc:     Dario Binacchi <dario.binacchi@...rulasolutions.com>,
        linux-kernel@...r.kernel.org, Joerg Roedel <joro@...tes.org>,
        Jonathan Hunter <jonathanh@...dia.com>,
        Krishna Reddy <vdumpa@...dia.com>,
        Robin Murphy <robin.murphy@....com>,
        Will Deacon <will@...nel.org>, iommu@...ts.linux.dev,
        linux-tegra@...r.kernel.org
Subject: Re: [PATCH] iommu/tegra-smmu: fix error checking for
 debugfs_create_dir()

On Wed, Oct 25, 2023 at 07:25:50PM +0800, Baolu Lu wrote:
> On 2023/10/25 19:01, Dario Binacchi wrote:
> > The return value of debugfs_create_dir() should be checked using the
> > IS_ERR() function.
> > 
> > Signed-off-by: Dario Binacchi <dario.binacchi@...rulasolutions.com>
> > ---
> > 
> >   drivers/iommu/tegra-smmu.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> > index e445f80d0226..cd1d80c4c673 100644
> > --- a/drivers/iommu/tegra-smmu.c
> > +++ b/drivers/iommu/tegra-smmu.c
> > @@ -1056,7 +1056,7 @@ DEFINE_SHOW_ATTRIBUTE(tegra_smmu_clients);
> >   static void tegra_smmu_debugfs_init(struct tegra_smmu *smmu)
> >   {
> >   	smmu->debugfs = debugfs_create_dir("smmu", NULL);
> > -	if (!smmu->debugfs)
> > +	if (IS_ERR(smmu->debugfs))
> >   		return;
> 
> This check can be removed, as debugfs_create_file() can handle the case
> where @parent is an error pointer.

A patch for this has been in linux-next for a few weeks, see:

commit f7da9c081517daba70f9f9342e09d7a6322ba323
Author: Jinjie Ruan <ruanjinjie@...wei.com>
Date:   Fri Sep 1 15:30:56 2023 +0800

    iommu/tegra-smmu: Drop unnecessary error check for for debugfs_create_dir()
    
    The debugfs_create_dir() function returns error pointers.
    It never returns NULL.
    
    As Baolu suggested, this patch removes the error checking for
    debugfs_create_dir in tegra-smmu.c. This is because the DebugFS kernel API
    is developed in a way that the caller can safely ignore the errors that
    occur during the creation of DebugFS nodes. The debugfs APIs have
    a IS_ERR() judge in start_creating() which can handle it gracefully. So
    these checks are unnecessary.
    
    Fixes: d1313e7896e9 ("iommu/tegra-smmu: Add debugfs support")
    Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
    Suggested-by: Baolu Lu <baolu.lu@...ux.intel.com>
    Acked-by: Thierry Reding <treding@...dia.com>
    Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
    Link: https://lore.kernel.org/r/20230901073056.1364755-1-ruanjinjie@huawei.com
    Signed-off-by: Joerg Roedel <jroedel@...e.de>

Thierry

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ