Skip to content

Commit

Permalink
staging: greybus: spilib: fix use-after-free after deregistration
Browse files Browse the repository at this point in the history
Remove erroneous spi_master_put() after controller deregistration which
would access the already freed spi controller.

Note that spi_unregister_master() drops our only controller reference.

Fixes: ba3e670 ("greybus: SPI: convert to a gpbridge driver")
Cc: stable <[email protected]>     # 4.9
Signed-off-by: Johan Hovold <[email protected]>
Reviewed-by: Rui Miguel Silva <[email protected]>
Acked-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jhovold authored and gregkh committed Nov 2, 2017
1 parent 1dc2f73 commit 770b03c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/staging/greybus/spilib.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,14 @@ int gb_spilib_master_init(struct gb_connection *connection, struct device *dev,

return 0;

exit_spi_unregister:
spi_unregister_master(master);
exit_spi_put:
spi_master_put(master);

return ret;

exit_spi_unregister:
spi_unregister_master(master);

return ret;
}
EXPORT_SYMBOL_GPL(gb_spilib_master_init);
Expand All @@ -558,7 +561,6 @@ void gb_spilib_master_exit(struct gb_connection *connection)
struct spi_master *master = gb_connection_get_data(connection);

spi_unregister_master(master);
spi_master_put(master);
}
EXPORT_SYMBOL_GPL(gb_spilib_master_exit);

Expand Down

0 comments on commit 770b03c

Please sign in to comment.