linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch -target tree] usb: gadget: f_tcm: use after free
@ 2016-03-02 10:08 Dan Carpenter
  2016-03-02 11:55 ` Felipe Balbi
  2016-03-05  7:20 ` Nicholas A. Bellinger
  0 siblings, 2 replies; 10+ messages in thread
From: Dan Carpenter @ 2016-03-02 10:08 UTC (permalink / raw)
  To: Felipe Balbi, Christoph Hellwig, Nicholas Bellinger
  Cc: Greg Kroah-Hartman, Sebastian Andrzej Siewior,
	Andrzej Pietrasiewicz, Bart Van Assche, linux-usb, linux-kernel,
	target-devel

We need to move the kfree() down a line so we don't dereference a freed
variable.

Fixes: 1b418a8fcbc0 ('target: Convert demo-mode only drivers to target_alloc_session')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index 7276a73..e352a31 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1596,8 +1596,8 @@ static int tcm_usbg_make_nexus(struct usbg_tpg *tpg, char *name)
 #define MAKE_NEXUS_MSG "core_tpg_check_initiator_node_acl() failed for %s\n"
 		pr_debug(MAKE_NEXUS_MSG, name);
 #undef MAKE_NEXUS_MSG
-		kfree(tv_nexus);
 		ret = PTR_ERR(tv_nexus->tvn_se_sess);
+		kfree(tv_nexus);
 	}
 
 out_unlock:

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

end of thread, other threads:[~2016-03-11  4:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-02 10:08 [patch -target tree] usb: gadget: f_tcm: use after free Dan Carpenter
2016-03-02 11:55 ` Felipe Balbi
2016-03-05  7:26   ` Nicholas A. Bellinger
2016-03-09 11:38     ` Felipe Balbi
2016-03-10  6:23       ` Nicholas A. Bellinger
2016-03-09 12:53     ` Andrzej Pietrasiewicz
2016-03-10  5:19       ` Nicholas A. Bellinger
2016-03-10  8:34         ` Andrzej Pietrasiewicz
2016-03-11  4:10           ` Nicholas A. Bellinger
2016-03-05  7:20 ` Nicholas A. Bellinger

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