Skip to content

Commit

Permalink
fpga: do not access region struct after fpga_region_unregister
Browse files Browse the repository at this point in the history
A couple drivers were accessing the region struct after it had been
freed.  Save off the pointer to the mgr before the region struct gets
freed.

Signed-off-by: Alan Tull <atull@kernel.org>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
atull-altera authored and gregkh committed Sep 30, 2018
1 parent 41e270f commit 34bd283
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion drivers/fpga/dfl-fme-region.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include <linux/module.h>
#include <linux/fpga/fpga-mgr.h>
#include <linux/fpga/fpga-region.h>

#include "dfl-fme-pr.h"
Expand Down Expand Up @@ -66,9 +67,10 @@ static int fme_region_probe(struct platform_device *pdev)
static int fme_region_remove(struct platform_device *pdev)
{
struct fpga_region *region = dev_get_drvdata(&pdev->dev);
struct fpga_manager *mgr = region->mgr;

fpga_region_unregister(region);
fpga_mgr_put(region->mgr);
fpga_mgr_put(mgr);

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/fpga/of-fpga-region.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,10 @@ static int of_fpga_region_probe(struct platform_device *pdev)
static int of_fpga_region_remove(struct platform_device *pdev)
{
struct fpga_region *region = platform_get_drvdata(pdev);
struct fpga_manager *mgr = region->mgr;

fpga_region_unregister(region);
fpga_mgr_put(region->mgr);
fpga_mgr_put(mgr);

return 0;
}
Expand Down

0 comments on commit 34bd283

Please sign in to comment.