From patchwork Wed Mar 20 02:29:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nil Yi X-Patchwork-Id: 10860725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE72913B5 for ; Wed, 20 Mar 2019 02:29:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A786128AF4 for ; Wed, 20 Mar 2019 02:29:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9F6294D4; Wed, 20 Mar 2019 02:29:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38A8428AF4 for ; Wed, 20 Mar 2019 02:29:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbfCTC3u (ORCPT ); Tue, 19 Mar 2019 22:29:50 -0400 Received: from m12-17.163.com ([220.181.12.17]:60027 "EHLO m12-17.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbfCTC3u (ORCPT ); Tue, 19 Mar 2019 22:29:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=3BoGb okQfCQQIZJlRdQTzKiuiu50+zqISaPR0F07JZw=; b=TPkqCwOWFAQ+QQZYm81OO TiqX+uHETX2mzFLkHJzJH8qBJdLnYZkq2XOSC+cHgp27BANxJZ6JV9luMf7K+MuR CtE9QOCIz4taHVvSzmpdX6kkmSZLjRiUncXiQ4iwDtMrwGKJCzrRH6MOeY9QAiDT LLlHdvpDuHcr4oO+4UW0S0= Received: from tero-machine (unknown [124.16.85.186]) by smtp13 (Coremail) with SMTP id EcCowADXr9N6pZFclwZfLw--.24996S3; Wed, 20 Mar 2019 10:29:14 +0800 (CST) Date: Wed, 20 Mar 2019 10:29:16 +0800 From: Lin Yi To: linux-usb@vger.kernel.org Cc: gregkh@linuxfoundation.org, zhiyunq@cs.ucr.edu, csong@cs.ucr.edu, ljian236@gmail.com, yiqiuping@gmail.com Subject: [PATCH] usb-serial: fix mos_parport refcount imbalance on error path Message-ID: <20190320022916.GA5199@163.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CM-TRANSID: EcCowADXr9N6pZFclwZfLw--.24996S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr17Cr4rCF1xuw17WF1xZrb_yoWDuFgEkr nY9rnIgrW8CF1fJr12q345GrWDK3WDXa93ZFnY9FZ0yFsY9r9rtF17Ar1kCw4DXayfXF98 Jwnxurn3AF1UGjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUYT6wtUUUUU== X-Originating-IP: [124.16.85.186] X-CM-SenderInfo: 5whu0xxqfqqiywtou0bp/1tbiLxp9ElUMLQ13VAAAsA Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP write_parport_ref_nonblock increase mos_parport refcount without decrease it when return -ENOMEM code, so need a decrement before function return -ENOMEM. Signed-off-by: Lin Yi --- drivers/usb/serial/mos7720.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index fc52ac7..6abb335 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -371,12 +371,14 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport, urbtrack->urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urbtrack->urb) { kfree(urbtrack); + kref_put(&mos_parport->ref_count, destroy_mos_parport); return -ENOMEM; } urbtrack->setup = kmalloc(sizeof(*urbtrack->setup), GFP_ATOMIC); if (!urbtrack->setup) { usb_free_urb(urbtrack->urb); kfree(urbtrack); + kref_put(&mos_parport->ref_count, destroy_mos_parport); return -ENOMEM; } urbtrack->setup->bRequestType = (__u8)0x40;