linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev
@ 2020-11-25  6:50 Qinglang Miao
  2020-11-25  9:22 ` kernel test robot
  2020-11-25 10:06 ` Wu, Hao
  0 siblings, 2 replies; 4+ messages in thread
From: Qinglang Miao @ 2020-11-25  6:50 UTC (permalink / raw)
  To: Wu Hao, Tom Rix, Moritz Fischer; +Cc: linux-fpga, linux-kernel, Qinglang Miao

platform_device_put is missing when it fails to set fdev->id. Set
a temp value to do sanity check.

Fixes: 543be3d8c999 ("fpga: add device feature list support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
 drivers/fpga/dfl.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index b450870b7..8958f0860 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -877,10 +877,13 @@ 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)
-		return fdev->id;
+	int tmp_id = dfl_id_alloc(type, &fdev->dev);
+	if (tmp_id < 0) {
+		platform_device_put(fdev);
+		return tmp_id;
+	}
 
+	fdev->id = tmp_id;
 	fdev->dev.parent = &binfo->cdev->region->dev;
 	fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-26  1:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-25  6:50 [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev Qinglang Miao
2020-11-25  9:22 ` kernel test robot
2020-11-25 10:06 ` Wu, Hao
2020-11-26  1:17   ` Qinglang Miao

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).