Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754266AbbDMXgr (ORCPT ); Mon, 13 Apr 2015 19:36:47 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48409 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbbDMXgp (ORCPT ); Mon, 13 Apr 2015 19:36:45 -0400 Date: Tue, 14 Apr 2015 09:36:34 +1000 From: NeilBrown To: Olivier Sobrie , "David S. Miller" , Jan Dumon Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, GTA04 owners Subject: [PATCH] hso: fix refcnt leak in recent patch. Message-ID: <20150414093634.4fe24ba3@notabene.brown> X-Mailer: Claws Mail 3.10.1-162-g4d0ed6 (GTK+ 2.24.25; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/PYbU3c00gd2=sKDuYNj6pgy"; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2404 Lines: 70 --Sig_/PYbU3c00gd2=sKDuYNj6pgy Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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 Signed-off-by: NeilBrown 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, st= ruct file *filp) } } else { D1("Port was already open"); + kref_get(&serial->parent->ref); } =20 usb_autopm_put_interface(serial->parent->interface); --Sig_/PYbU3c00gd2=sKDuYNj6pgy Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIVAwUBVSxTAjnsnt1WYoG5AQIEOA/+MvJxANmt5k8pIpodsslXNQoiixv43X/E yJoZYLice2S+TADLCfT4wO1O/eMHtWMRUQUARI2grLWx2ZUQV5Bka7d2JgxeXv6M OTj++3PpquMNmB0TQOD9axPu2f41gvgCz1dex/RaZWjJYstIBimDIE25Vc3keFMO w1pEC6CxFRd2NJysOCNz6YtptHoBOuieAem1/jkeT9FgeB/DeStoKWMJ6O+eM+b9 tYaUcVVoXbL+++G/y4iv5N8zjonC374oz7gfp5ltShX2IRyd5YXZTPGzd7MW5IAF PfbECn4qF2qKSLgo8NNbeu5ZWXgj+3AZF9GsZHSbWoV1YqxbQsFxe1S/qI/ZbNvp qqBfQPMurUi9xHthckpqRZKpl3y3xwmbMyAiiCNis7hxk8EsPnj/Qzum9WZ4phP5 /w3MSXa0Q/buDdyI4UxCDOJIbO3aics8H0r5HKk5WyyZGFymbUp+KEy8POlcgTcr CyfprrOei4QwTDuk4FdMy2Bk2fTRo0ul6e+vLytF6FpISKQsTjPJsf0wimQQDKWA jpufLiHkx9p0OWzC1WcamrLNdx5mg6NmjayA9IMGtKOYgiUUIgwXN8/IPdTe85hZ djY24luLKzaRjIsw4HaGl2O74wZi6Gi5mXwYt4FNsF2z13WbAFkDXxKc4l98gla9 HY4lbiGEhCc= =bji5 -----END PGP SIGNATURE----- --Sig_/PYbU3c00gd2=sKDuYNj6pgy-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/