From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88C65C43381 for ; Fri, 29 Mar 2019 14:46:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55DD02184D for ; Fri, 29 Mar 2019 14:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553870811; bh=SRM1eXNZO9E6QW6skLE6KCZPm8WU24RztdHX79Gnvug=; h=Subject:To:From:Date:List-ID:From; b=ENNo8yQNthCHxJVBXkjwxkdXSyNrFF+CNEZBmr7GLrSgudi4moPmOzPrsmi2gDI7S 2fJ1dkijunLhVsjrN6wNWx7n/xQjQaOfmNMGVCVqW05q9wqiU4n8Qkxux4tsPYfTc9 vVCJ4o2h4L0LmH/pbbh1rX44KnyzabZtPgTa0Zsk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729334AbfC2Oqv (ORCPT ); Fri, 29 Mar 2019 10:46:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:34434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbfC2Oqu (ORCPT ); Fri, 29 Mar 2019 10:46:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFC992184C; Fri, 29 Mar 2019 14:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553870810; bh=SRM1eXNZO9E6QW6skLE6KCZPm8WU24RztdHX79Gnvug=; h=Subject:To:From:Date:From; b=FfNd9pmOeoqE1uqoYdeF1nggC5k0Tek5vLNobywueDvUPHJqUEwJ9Nroy/DsXJsWI gMb86LH+Eg5YAKyMEf+ZMzqpk47VRRrrWwIp2W7obU+pZYMPbMdJGevUmMlRYqH0cU /nIjCqjU3qpGVDm4ZQdCiHL3QxuyhFa68I7F9xKI= Subject: patch "USB: serial: mos7720: fix mos_parport refcount imbalance on error" added to usb-linus To: teroincn@163.com, johan@kernel.org, stable@vger.kernel.org From: Date: Fri, 29 Mar 2019 15:46:30 +0100 Message-ID: <15538707905195@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is a note to let you know that I've just added the patch titled USB: serial: mos7720: fix mos_parport refcount imbalance on error to my usb git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git in the usb-linus branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will hopefully also be merged in Linus's tree for the next -rc kernel release. If you have any questions about this process, please let me know. >From 2908b076f5198d231de62713cb2b633a3a4b95ac Mon Sep 17 00:00:00 2001 From: Lin Yi Date: Wed, 20 Mar 2019 19:04:56 +0800 Subject: USB: serial: mos7720: fix mos_parport refcount imbalance on error path The write_parport_reg_nonblock() helper takes a reference to the struct mos_parport, but failed to release it in a couple of error paths after allocation failures, leading to a memory leak. Johan said that move the kref_get() and mos_parport assignment to the end of urbtrack initialisation is a better way, so move it. and mos_parport do not used until urbtrack initialisation. Signed-off-by: Lin Yi Fixes: b69578df7e98 ("USB: usbserial: mos7720: add support for parallel port on moschip 7715") Cc: stable # 2.6.35 Signed-off-by: Johan Hovold --- drivers/usb/serial/mos7720.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index fc52ac75fbf6..18110225d506 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -366,8 +366,6 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport, if (!urbtrack) return -ENOMEM; - kref_get(&mos_parport->ref_count); - urbtrack->mos_parport = mos_parport; urbtrack->urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urbtrack->urb) { kfree(urbtrack); @@ -388,6 +386,8 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport, usb_sndctrlpipe(usbdev, 0), (unsigned char *)urbtrack->setup, NULL, 0, async_complete, urbtrack); + kref_get(&mos_parport->ref_count); + urbtrack->mos_parport = mos_parport; kref_init(&urbtrack->ref_count); INIT_LIST_HEAD(&urbtrack->urblist_entry); -- 2.21.0