From: Xidong Wang <wangxidong_97@163.com> To: Boris Brezillon <boris.brezillon@free-electrons.com>, Richard Weinberger <richard@nod.at>, David Woodhouse <dwmw2@infradead.org>, Brian Norris <computersforpeace@gmail.com>, Marek Vasut <marek.vasut@gmail.com>, Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>, Marc Gonzalez <marc.w.gonzalez@free.fr>, Mans Rullgard <mans@mansr.com> Cc: Xidong Wang <wangxidong_97@163.com>, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] mtd:nand:fix memory leak Date: Wed, 4 Apr 2018 11:05:51 +0800 [thread overview] Message-ID: <1522811151-18853-1-git-send-email-wangxidong_97@163.com> (raw) In function tango_nand_probe(), the memory allocated by clk_get() is not released on the normal path and the error path that IS_ERR(nfc->chan) returns true. This will result in a memory leak bug. Signed-off-by: Xidong Wang <wangxidong_97@163.com> --- drivers/mtd/nand/tango_nand.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c index c5bee00b..8083459 100644 --- a/drivers/mtd/nand/tango_nand.c +++ b/drivers/mtd/nand/tango_nand.c @@ -648,12 +648,15 @@ static int tango_nand_probe(struct platform_device *pdev) return PTR_ERR(clk); nfc->chan = dma_request_chan(&pdev->dev, "rxtx"); - if (IS_ERR(nfc->chan)) + if (IS_ERR(nfc->chan)) { + clk_put(clk); return PTR_ERR(nfc->chan); + } platform_set_drvdata(pdev, nfc); nand_hw_control_init(&nfc->hw); nfc->freq_kHz = clk_get_rate(clk) / 1000; + clk_put(clk); for_each_child_of_node(pdev->dev.of_node, np) { err = chip_init(&pdev->dev, np); -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: wangxidong_97@163.com (Xidong Wang) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/1] mtd:nand:fix memory leak Date: Wed, 4 Apr 2018 11:05:51 +0800 [thread overview] Message-ID: <1522811151-18853-1-git-send-email-wangxidong_97@163.com> (raw) In function tango_nand_probe(), the memory allocated by clk_get() is not released on the normal path and the error path that IS_ERR(nfc->chan) returns true. This will result in a memory leak bug. Signed-off-by: Xidong Wang <wangxidong_97@163.com> --- drivers/mtd/nand/tango_nand.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c index c5bee00b..8083459 100644 --- a/drivers/mtd/nand/tango_nand.c +++ b/drivers/mtd/nand/tango_nand.c @@ -648,12 +648,15 @@ static int tango_nand_probe(struct platform_device *pdev) return PTR_ERR(clk); nfc->chan = dma_request_chan(&pdev->dev, "rxtx"); - if (IS_ERR(nfc->chan)) + if (IS_ERR(nfc->chan)) { + clk_put(clk); return PTR_ERR(nfc->chan); + } platform_set_drvdata(pdev, nfc); nand_hw_control_init(&nfc->hw); nfc->freq_kHz = clk_get_rate(clk) / 1000; + clk_put(clk); for_each_child_of_node(pdev->dev.of_node, np) { err = chip_init(&pdev->dev, np); -- 2.7.4
next reply other threads:[~2018-04-04 3:07 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-04-04 3:05 Xidong Wang [this message] 2018-04-04 3:05 ` [PATCH 1/1] mtd:nand:fix memory leak Xidong Wang 2018-04-04 6:28 ` Miquel Raynal 2018-04-04 7:07 ` Boris Brezillon 2018-04-04 7:08 ` Boris Brezillon 2018-04-05 9:12 ` Marc Gonzalez 2018-04-05 9:44 ` Miquel Raynal 2018-04-05 11:04 ` Boris Brezillon 2018-04-05 9:54 ` Boris Brezillon 2018-04-05 11:26 ` Marc Gonzalez 2018-04-05 11:47 ` Boris Brezillon 2018-04-05 12:00 ` Marc Gonzalez 2018-04-05 12:57 ` [PATCH v2] mtd: rawnand: tango: Fix struct clk " Marc Gonzalez 2018-04-05 14:22 ` Miquel Raynal 2018-04-24 15:50 ` Boris Brezillon
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1522811151-18853-1-git-send-email-wangxidong_97@163.com \ --to=wangxidong_97@163.com \ --cc=boris.brezillon@free-electrons.com \ --cc=computersforpeace@gmail.com \ --cc=cyrille.pitchen@wedev4u.fr \ --cc=dwmw2@infradead.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mtd@lists.infradead.org \ --cc=mans@mansr.com \ --cc=marc.w.gonzalez@free.fr \ --cc=marek.vasut@gmail.com \ --cc=richard@nod.at \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.