From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757678AbcAJXQ2 (ORCPT ); Sun, 10 Jan 2016 18:16:28 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50987 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757294AbcAJXQ0 (ORCPT ); Sun, 10 Jan 2016 18:16:26 -0500 Message-ID: <1452467777.2435.66.camel@decadent.org.uk> Subject: Re: [PATCH v2 09/19] staging/speakup: Use tty_ldisc_ref() for paste kworker From: Ben Hutchings To: Peter Hurley , Greg Kroah-Hartman Cc: Jiri Slaby , linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Sun, 10 Jan 2016 23:16:17 +0000 In-Reply-To: <1452400870-6005-10-git-send-email-peter@hurleysoftware.com> References: <1448660356-6328-1-git-send-email-peter@hurleysoftware.com> <1452400870-6005-1-git-send-email-peter@hurleysoftware.com> <1452400870-6005-10-git-send-email-peter@hurleysoftware.com> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-2ebaGs6PlPu8Zl/04NGU" X-Mailer: Evolution 3.18.3-1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.4.247 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-2ebaGs6PlPu8Zl/04NGU Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 2016-01-09 at 20:41 -0800, Peter Hurley wrote: > As the function documentation for tty_ldisc_ref_wait() notes, it is > only callable from a tty file_operations routine; otherwise there > is no guarantee the ref won't be NULL. >=20 > The key difference with the VT's paste_selection() is that is an ioctl, > where __speakup_paste_selection() is completely asynch kworker, kicked > off from interrupt context. >=20 > Fixes: 28a821c30688 ("Staging: speakup: Update __speakup_paste_selection(= ) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0tty (ab)usage to match vt") > Cc: >=20 > Signed-off-by: Peter Hurley > --- > =C2=A0drivers/staging/speakup/selection.c | 4 +++- > =C2=A01 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speaku= p/selection.c > index aa5ab6c..86c0b9a 100644 > --- a/drivers/staging/speakup/selection.c > +++ b/drivers/staging/speakup/selection.c > @@ -142,7 +142,9 @@ static void __speakup_paste_selection(struct work_str= uct *work) > =C2=A0 struct tty_ldisc *ld; > =C2=A0 DECLARE_WAITQUEUE(wait, current); > =C2=A0 > - ld =3D tty_ldisc_ref_wait(tty); > + ld =3D tty_ldisc_ref(tty); > + if (!ld) > + return; > =C2=A0 tty_buffer_lock_exclusive(&vc->port); > =C2=A0 > =C2=A0 add_wait_queue(&vc->paste_wait, &wait); This leaks a reference to the tty. =C2=A0Instead of returning directly, I think you need to add a label and goto the tty_kref_put() at the bottom of the function. Ben. --=20 Ben Hutchings Power corrupts. Absolute power is kind of neat. - John Lehman, Secretary of the US Navy 1981-198= 7 --=-2ebaGs6PlPu8Zl/04NGU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIVAwUAVpLmQee/yOyVhhEJAQrepw/5AZh7O+FRWFGdeoq8nJ5ihuWKBzLH9pVV 4q3+xpmTEwrFuXQQ6T+uo/XjAtTX8BBTma8zlpRIwxRTjxRt5eUfEaejnA+BEmwu hsI6gS39b9zLOvTXnD1+BwPIa9XWhr/tJPiiqlYAPtrXSkEG2py/hOBcIYHxB7Pe DDw0HdqKnchUDkue5DbUKqS4W16zRXGu4lPiGpI0TsrN/KqfsU97KaSzqurLIPYX LKoKlCl5udKxVYgjB+B5d+ymO1P8Z/R9vYaqMcMtfcebjW39X6AD2yYOXDRlN0e/ fxq+hS+sPfksfaHUTcM9VYNcAz1gxR2HTJbadE2vnX23cKOeJ1dQxKFhH4g5UZ2g pf5DUkdyo3UGFLb0zrQ4qRKKrc7SSYZ1zvE5vykvCUqWoAWgdncYBDSw5bPdD4EB V/PvDxfh8JXwlBvstqrNaLG3a7dFN3NYwmj06nl71JpNILOqxTfAOhlpxDEb/VkO EtId44wdXMMUqaJ0dqpihWZ8s41QMjOzLihuY3NCrvHv6srNuwuqpD2ewJBzM2ZT tZigNFR4lBnCbxvk4xRje97dsxkcA0qXi+0R4T/YCmSwlBQAmB+fkuTv62dDQhHL 2txcOg5ZJ2C64bOEe3zTCkL33Z0DEO9BmNupoDfNOn/M7PQxlegnHkyp/JF+BAff s4fzoRoiOho= =1ZX1 -----END PGP SIGNATURE----- --=-2ebaGs6PlPu8Zl/04NGU--