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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 3 Sep 2019 19:55:42 -0700
From:   Andrey Smirnov <andrew.smirnov@...il.com>
To:     Fabio Estevam <festevam@...il.com>
Cc:     "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
        <linux-crypto@...r.kernel.org>, Chris Healy <cphealy@...il.com>,
        Lucas Stach <l.stach@...gutronix.de>,
        Horia Geantă <horia.geanta@....com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        Iuliana Prodan <iuliana.prodan@....com>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 02/12] crypto: caam - use devres to unmap JR's registers

On Tue, Sep 3, 2019 at 7:43 PM Fabio Estevam <festevam@...il.com> wrote:
>
> Hi Andrey,
>
> On Tue, Sep 3, 2019 at 11:37 PM Andrey Smirnov <andrew.smirnov@...il.com> wrote:
> >
> > Use devres to unmap memory and drop explicit de-initialization
> > code.
> >
> > NOTE: There's no corresponding unmapping code in caam_jr_remove which
> > seems like a resource leak.
> >
> > Signed-off-by: Andrey Smirnov <andrew.smirnov@...il.com>
> > Cc: Chris Healy <cphealy@...il.com>
> > Cc: Lucas Stach <l.stach@...gutronix.de>
> > Cc: Horia Geantă <horia.geanta@....com>
> > Cc: Herbert Xu <herbert@...dor.apana.org.au>
> > Cc: Iuliana Prodan <iuliana.prodan@....com>
> > Cc: linux-crypto@...r.kernel.org
> > Cc: linux-kernel@...r.kernel.org
> > ---
> >  drivers/crypto/caam/jr.c | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
> > index 417ad52615c6..7947d61a25cf 100644
> > --- a/drivers/crypto/caam/jr.c
> > +++ b/drivers/crypto/caam/jr.c
> > @@ -498,6 +498,7 @@ static int caam_jr_probe(struct platform_device *pdev)
> >         struct caam_job_ring __iomem *ctrl;
> >         struct caam_drv_private_jr *jrpriv;
> >         static int total_jobrs;
> > +       struct resource *r;
> >         int error;
> >
> >         jrdev = &pdev->dev;
> > @@ -513,9 +514,15 @@ static int caam_jr_probe(struct platform_device *pdev)
> >         nprop = pdev->dev.of_node;
> >         /* Get configuration properties from device tree */
> >         /* First, get register page */
> > -       ctrl = of_iomap(nprop, 0);
> > +       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +       if (!r) {
> > +               dev_err(jrdev, "platform_get_resource() failed\n");
> > +               return -ENOMEM;
> > +       }
> > +
> > +       ctrl = devm_ioremap(jrdev, r->start, resource_size(r));
>
> It seems that using devm_platform_ioremap_resource() could make the
> code even smaller.

Unfortunately that function would do devm_ioremap_resource() under the
hood and claim the ownership of the corresponding memory region.
That's going to create a conflict with devm_of_iomap() used in
"crypto: caam - use devres to unmap memory".

Thanks,
Andrey Smirnov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ