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: <004e01ceeb05$9d579690$d806c3b0$%han@samsung.com>
Date:	Wed, 27 Nov 2013 09:14:18 +0900
From:	Jingoo Han <jg1.han@...sung.com>
To:	'Brian Norris' <computersforpeace@...il.com>
Cc:	'Wei Yongjun' <weiyj.lk@...il.com>,
	'David Woodhouse' <dwmw2@...radead.org>,
	'Bill Pemberton' <wfp5p@...ginia.edu>,
	'Artem Bityutskiy' <artem.bityutskiy@...ux.intel.com>,
	'Wei Yongjun' <yongjun_wei@...ndmicro.com.cn>,
	linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
	'Jingoo Han' <jg1.han@...sung.com>
Subject: Re: [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in
 au1550nd_probe()

On Wednesday, November 27, 2013 8:50 AM, Brian Norris wrote:

Hi Brian Norris,

I added my questions as below. :-)

> On Mon, Nov 11, 2013 at 02:18:29PM +0800, Wei Yongjun wrote:
> > From: Wei Yongjun <yongjun_wei@...ndmicro.com.cn>
> >
> > Add missing platform_set_drvdata() in au1550nd_probe(), otherwise
> > calling platform_get_drvdata() in remove returns NULL.
> 
> An alternative solution: just allocate ctx with devm_kzalloc().Then you
> don't have to kfree() it at all.

Even if devm_kzalloc() is used, missing platform_set_drvdata() will
be still necessary.

static int au1550nd_remove(struct platform_device *pdev)
{
	struct au1550nd_ctx *ctx = platform_get_drvdata(pdev);
	.....

	nand_release(&ctx->info);

'ctx' is still used. Also, in order to use 'ctx',
platform_get_drvdata(pdev) should be called.

> 
> I don't mind one solution over the other too much. Let me know which
> you'd prefer.
> 
> > Signed-off-by: Wei Yongjun <yongjun_wei@...ndmicro.com.cn>
> > ---
> >  drivers/mtd/nand/au1550nd.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
> > index ae8dd7c..909b673 100644
> > --- a/drivers/mtd/nand/au1550nd.c
> > +++ b/drivers/mtd/nand/au1550nd.c
> > @@ -480,6 +480,8 @@ static int au1550nd_probe(struct platform_device *pdev)
> >
> >  	mtd_device_register(&ctx->info, pd->parts, pd->num_parts);
> >
> > +	platform_set_drvdata(pdev, ctx);
> > +
> 
> Personally, I'd choose to call platform_set_drvdata() earlier in the
> probe routine (e.g., immediately after its allocation), in case we end
> up calling platform_get_drvdata() from some sub-routine in the future.

Do you mean the following?
But, most drivers calls platform_set_drvdata() later in the probe routine.

static int au1550nd_probe(struct platform_device *pdev)
{
        struct au1550nd_platdata *pd;
        struct au1550nd_ctx *ctx;
        struct nand_chip *this;
        struct resource *r;
        int ret, cs;

        pd = dev_get_platdata(&pdev->dev);
        if (!pd) {
                dev_err(&pdev->dev, "missing platform data\n");
                return -ENODEV;
        }

        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (!ctx) {
                dev_err(&pdev->dev, "no memory for NAND context\n");
                return -ENOMEM;
        }

+	platform_set_drvdata(pdev, ctx);
+

Best regards,
Jingoo Han

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ