From: Miaoqian Lin <linmq006@gmail.com>
To: Wu Hao <hao.wu@intel.com>, Tom Rix <trix@redhat.com>,
Moritz Fischer <mdf@kernel.org>, Xu Yilun <yilun.xu@intel.com>,
Tim Whisonant <tim.whisonant@intel.com>,
Enno Luebbers <enno.luebbers@intel.com>,
Alan Tull <atull@kernel.org>, Shiva Rao <shiva.rao@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com
Subject: [PATCH] fpga: Fix memory leak in build_info_create_dev
Date: Wed, 11 May 2022 10:44:00 +0400 [thread overview]
Message-ID: <20220511064400.63518-1-linmq006@gmail.com> (raw)
platform_device_alloc() create a platform device object.
we should call platform_device_put() in error path to
release the resource.
Fixes: 543be3d8c999 ("fpga: add device feature list support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/fpga/dfl.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index 599bb21d86af..f0b945bd975f 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -879,8 +879,10 @@ build_info_create_dev(struct build_feature_devs_info *binfo,
INIT_LIST_HEAD(&binfo->sub_features);
fdev->id = dfl_id_alloc(type, &fdev->dev);
- if (fdev->id < 0)
+ if (fdev->id < 0) {
+ platform_device_put(fdev);
return fdev->id;
+ }
fdev->dev.parent = &binfo->cdev->region->dev;
fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
--
2.25.1
next reply other threads:[~2022-05-11 6:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 6:44 Miaoqian Lin [this message]
2022-05-11 7:50 ` [PATCH] fpga: Fix memory leak in build_info_create_dev Xu Yilun
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=20220511064400.63518-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=atull@kernel.org \
--cc=enno.luebbers@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hao.wu@intel.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@kernel.org \
--cc=shiva.rao@intel.com \
--cc=tim.whisonant@intel.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).