Received: by 10.223.185.116 with SMTP id b49csp657293wrg; Fri, 16 Feb 2018 05:11:55 -0800 (PST) X-Google-Smtp-Source: AH8x2251VHjUMj6m51RL2MT/9/S+4rjwiyxHV5Jngl4njzVwMvAVx+lqfn/Sw4A/vlDHYSHKTK2w X-Received: by 2002:a17:902:834c:: with SMTP id z12-v6mr5595782pln.293.1518786715864; Fri, 16 Feb 2018 05:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518786715; cv=none; d=google.com; s=arc-20160816; b=OtmOOA38qpvtkltjgfsYCloqGzL+phZ2f5JPpV8COIeMH8ariNphZXO4TA9L0s9OPc ovFSlNdI6t4+fsMTVeZR7QAfUB8dI0Kjl6GDWf2REUkBOAqDtqqBxIMXgvIQIvL1SwV5 wq5+jTB83hZcP67KaNfQkUXbQukOCiSOzbCR4+VFWMrUuWe5gF3FkQxPsIH0BGYoOgNK nGJVom9Ac0grUIytHl9L6d3QJMcgGxbEvfTBb4fpkYttTdKo+MRyQ4rMxURFhyAn/dh6 LEhx7dZOvLgAhkQmGHkzLTG80B2HiOZFUkS/y2gRtlmPLUdfa5/giYlwkhPoeRq9T1k9 wxkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=exJc8aYvKkeu6/fAzoXBoHNGW3DIWMjh6XOtdVJ4sec=; b=Wl11MlX7IePbTIO4nyuzBSNLs8xSpa4n+PqbvHpHr8KRPEb5bd6rglf4zDeHM197R/ jrBE3R2NLD3R7JqGfnq9VqPqgo9LM+4i8bbBaLFgGkU8wIL2+bK6b5RO8XUgbqTHCcGW N2xQ3AY3C5tFamEfLAwQJ1j/7EoiNlC5la0C+h4wAaKJu4jDd1GMAgjgzzh6wdO8InCK RApRsci6dkjO2FgvxvmUMR/QzDxz+npZ/5LRJpJVBgFSwCdQ6+fxJX2reazKVc8cpzjY E4s54DBBYhuKHtPRr2PScPSW+8mzuvSsAj83Z72ch0iXuPOjYaG1EkKrrUH/iS7lc3fJ xj2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si1230008pfk.217.2018.02.16.05.11.41; Fri, 16 Feb 2018 05:11:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1166429AbeBOS0M (ORCPT + 99 others); Thu, 15 Feb 2018 13:26:12 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52448 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163271AbeBOPZz (ORCPT ); Thu, 15 Feb 2018 10:25:55 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DF3AE1137; Thu, 15 Feb 2018 15:25:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Yadav , Andrey Konovalov , Hans Verkuil , Mauro Carvalho Chehab , Ben Hutchings Subject: [PATCH 4.9 14/88] media: hdpvr: Fix an error handling path in hdpvr_probe() Date: Thu, 15 Feb 2018 16:16:41 +0100 Message-Id: <20180215151224.695159399@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.437136975@linuxfoundation.org> References: <20180215151222.437136975@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arvind Yadav commit c0f71bbb810237a38734607ca4599632f7f5d47f upstream. Here, hdpvr_register_videodev() is responsible for setup and register a video device. Also defining and initializing a worker. hdpvr_register_videodev() is calling by hdpvr_probe at last. So no need to flush any work here. Unregister v4l2, free buffers and memory. If hdpvr_probe() will fail. Signed-off-by: Arvind Yadav Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/hdpvr/hdpvr-core.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c @@ -295,7 +295,7 @@ static int hdpvr_probe(struct usb_interf /* register v4l2_device early so it can be used for printks */ if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) { dev_err(&interface->dev, "v4l2_device_register failed\n"); - goto error; + goto error_free_dev; } mutex_init(&dev->io_mutex); @@ -304,7 +304,7 @@ static int hdpvr_probe(struct usb_interf dev->usbc_buf = kmalloc(64, GFP_KERNEL); if (!dev->usbc_buf) { v4l2_err(&dev->v4l2_dev, "Out of memory\n"); - goto error; + goto error_v4l2_unregister; } init_waitqueue_head(&dev->wait_buffer); @@ -342,13 +342,13 @@ static int hdpvr_probe(struct usb_interf } if (!dev->bulk_in_endpointAddr) { v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n"); - goto error; + goto error_put_usb; } /* init the device */ if (hdpvr_device_init(dev)) { v4l2_err(&dev->v4l2_dev, "device init failed\n"); - goto error; + goto error_put_usb; } mutex_lock(&dev->io_mutex); @@ -356,7 +356,7 @@ static int hdpvr_probe(struct usb_interf mutex_unlock(&dev->io_mutex); v4l2_err(&dev->v4l2_dev, "allocating transfer buffers failed\n"); - goto error; + goto error_put_usb; } mutex_unlock(&dev->io_mutex); @@ -364,7 +364,7 @@ static int hdpvr_probe(struct usb_interf retval = hdpvr_register_i2c_adapter(dev); if (retval < 0) { v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n"); - goto error; + goto error_free_buffers; } client = hdpvr_register_ir_rx_i2c(dev); @@ -397,13 +397,17 @@ static int hdpvr_probe(struct usb_interf reg_fail: #if IS_ENABLED(CONFIG_I2C) i2c_del_adapter(&dev->i2c_adapter); +error_free_buffers: #endif + hdpvr_free_buffers(dev); +error_put_usb: + usb_put_dev(dev->udev); + kfree(dev->usbc_buf); +error_v4l2_unregister: + v4l2_device_unregister(&dev->v4l2_dev); +error_free_dev: + kfree(dev); error: - if (dev) { - flush_work(&dev->worker); - /* this frees allocated memory */ - hdpvr_delete(dev); - } return retval; }