]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
mwifiex: don't do unbalanced free()'ing in cleanup_if()
authorBrian Norris <briannorris@chromium.org>
Wed, 26 Oct 2016 23:29:20 +0000 (16:29 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 18 Nov 2016 11:23:12 +0000 (13:23 +0200)
commit66b9c182538e2ed11d31120e853321e4ea6f3e5a
treec6204e3f6ee702205d7c301f03fe0977e668490b
parent14e5e937592697d830537b7f6a59d45a6aa3d51b
mwifiex: don't do unbalanced free()'ing in cleanup_if()

The cleanup_if() callback is the inverse of init_if(). We allocate our
'card' interface structure in the probe() function, but we free it in
cleanup_if(). That gives a few problems:
(a) we leak this memory if probe() fails before we reach init_if()
(b) we can't safely utilize 'card' after cleanup_if() -- namely, in
    remove() or suspend(), both of which might race with the cleanup
    paths in our asynchronous FW initialization path

Solution: just use devm_kzalloc(), which will free this structure
properly when the device is removed -- and drop the set_drvdata(...,
NULL), since the driver core does this for us. This also removes the
temptation to use drvdata == NULL as a hack for checking if the device
has been "cleaned up."

I *do* leave the set_drvdata(..., NULL) for the hacky SDIO
mwifiex_recreate_adapter(), since the device core won't be able to clear
that one for us.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/pcie.c
drivers/net/wireless/marvell/mwifiex/sdio.c
drivers/net/wireless/marvell/mwifiex/usb.c