From patchwork Sat Jan 18 23:24:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 3508741 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41830C02DC for ; Sat, 18 Jan 2014 23:24:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BD952013A for ; Sat, 18 Jan 2014 23:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E66F920127 for ; Sat, 18 Jan 2014 23:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751774AbaARXYh (ORCPT ); Sat, 18 Jan 2014 18:24:37 -0500 Received: from mail.ispras.ru ([83.149.199.45]:44903 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751790AbaARXYh (ORCPT ); Sat, 18 Jan 2014 18:24:37 -0500 Received: from localhost.localdomain (ppp91-77-198-23.pppoe.mtu-net.ru [91.77.198.23]) by mail.ispras.ru (Postfix) with ESMTPSA id 13409540157; Sun, 19 Jan 2014 03:24:35 +0400 (MSK) From: Alexey Khoroshilov To: Dmitry Torokhov , Greg Kroah-Hartman Cc: Alexey Khoroshilov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] USB: input: gtco.c: fix usb_dev leak Date: Sun, 19 Jan 2014 03:24:26 +0400 Message-Id: <1390087466-9898-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.8.3.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is usb_get_dev() in gtco_probe(), but there is no usb_put_dev() anywhere in the driver. The patch adds usb_get_dev() to failure handling code of gtco_probe() and to gtco_disconnect((). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/input/tablet/gtco.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c index 29e01ab6859f..6ec8a3a04672 100644 --- a/drivers/input/tablet/gtco.c +++ b/drivers/input/tablet/gtco.c @@ -858,7 +858,7 @@ static int gtco_probe(struct usb_interface *usbinterface, if (!gtco->buffer) { dev_err(&usbinterface->dev, "No more memory for us buffers\n"); error = -ENOMEM; - goto err_free_devs; + goto err_put_usb; } /* Allocate URB for reports */ @@ -990,6 +990,8 @@ static int gtco_probe(struct usb_interface *usbinterface, err_free_buf: usb_free_coherent(gtco->usbdev, REPORT_MAX_SIZE, gtco->buffer, gtco->buf_dma); + err_put_usb: + usb_put_dev(gtco->usbdev); err_free_devs: input_free_device(input_dev); kfree(gtco); @@ -1013,6 +1015,7 @@ static void gtco_disconnect(struct usb_interface *interface) usb_free_urb(gtco->urbinfo); usb_free_coherent(gtco->usbdev, REPORT_MAX_SIZE, gtco->buffer, gtco->buf_dma); + usb_put_dev(gtco->usbdev); kfree(gtco); }