netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hso: fix refcnt leak in recent patch.
@ 2015-04-13 23:36 NeilBrown
       [not found] ` <20150414093634.4fe24ba3-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: NeilBrown @ 2015-04-13 23:36 UTC (permalink / raw)
  To: Olivier Sobrie, David S. Miller, Jan Dumon
  Cc: linux-usb, netdev, linux-kernel, GTA04 owners

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]



Prior to
commit 29bd3bc1194c624ce863cab2a7da9bc1f0c3b47b
    hso: fix crash when device disappears while serial port is open

hso_serial_open would always kref_get(&serial->parent->ref) before
returning zero.
Since that commit, it only calls kref_get when returning 0 if
serial->port.count was zero.

This results in calls to
       kref_put(&serial->parent->ref, hso_serial_ref_free);

after hso_serial_ref_free has been called, which dereferences a freed
pointer.

This patch adds the missing kref_get().

Fixes: commit 29bd3bc1194c624ce863cab2a7da9bc1f0c3b47b
Cc: stable@vger.kernel.org (v4.0)
Cc: Olivier Sobrie <olivier@sobrie.be>
Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 75befc1bd816..6848fc903340 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1299,6 +1299,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
 		}
 	} else {
 		D1("Port was already open");
+		kref_get(&serial->parent->ref);
 	}
 
 	usb_autopm_put_interface(serial->parent->interface);

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

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

end of thread, other threads:[~2015-04-16 13:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-13 23:36 [PATCH] hso: fix refcnt leak in recent patch NeilBrown
     [not found] ` <20150414093634.4fe24ba3-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-04-14  1:03   ` NeilBrown
     [not found]     ` <20150414110303.66edcfee-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-04-14  6:50       ` Olivier Sobrie
2015-04-14  7:35         ` NeilBrown
2015-04-16 13:21     ` Olivier Sobrie

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