Received: by 10.223.185.116 with SMTP id b49csp556391wrg; Fri, 16 Feb 2018 03:31:19 -0800 (PST) X-Google-Smtp-Source: AH8x2253HwWyyqCBnY1DKf/Z9LTaXZDdKj20lrxnyf0zjnqZfe2Xw8F0BRkwQETNIME5nMwjM4lh X-Received: by 2002:a17:902:5854:: with SMTP id f20-v6mr5612937plj.374.1518780679525; Fri, 16 Feb 2018 03:31:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518780679; cv=none; d=google.com; s=arc-20160816; b=0Z3WohHQRA5Z3eWpopZNLyCqqVz6TLM08tRILIyuMB8en4sU3UJZG+tz7vAxDDy4B9 R56Apyo3yLqvxlVlqYAxoLF0NJrZe4Hb5Uv6Ox1Yo0ZQyE+lx+t4K4NkMXBfp77i73xu vzUzc58KfiMhPy73bWZHZX0qYlc+UKcbJ8T71NS/xLwzStXzhbFxkTLgkAfZDW3a1Fs9 GaYnkMlQdz3s0t4b+iPvLm9aEnBjVEdaX9HX/3JV/X/JsArJvtaCK3hWIWzZQmMvaiNo bEY4+fLMTJpxQ7Wgko+g43ZKuUO79W8Q7PI7wTXQ6Z9o8teSi2oR04J9M/J0/QPtlEb9 bYmg== 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=iSc3ShXSJ6fAvjLKqlm8PFJzhucKuqwjsuZboFzNwwU=; b=aQ7R6ZvqUeHmngvUOo4Q67XBNEttsgLnt1idNBtaGmJq94/THQiu1eAE9nfB2ucXnd iKuomC6J/usllj5Y/RHZIdTGZWyeJhHo38fBDjnfSjjIZXwwfNIfu/bWsNviLKGevNBl bCMgPhOS5Xt3CQ+fd9hf7ZiXGm7QcwHcIwGsChTe0+80gFlnHpTS3UrUa9/TZkRAAjXL /FwQAH8qXKPu6hp2TLbWiUvPmoi63gaKveYZ2xx6G1Bxggb1Xyp5L8ph2z4PgYNODi+x 5HWqJOtZ2kBqeMb0z3RAJWRO1d6UDzqrcfMzrbHtT3hf2kEL5k82RMFjQdcEQoIObdXg y+1Q== 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 m16si5367062pgn.290.2018.02.16.03.31.04; Fri, 16 Feb 2018 03:31:19 -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 S1427545AbeBORwq (ORCPT + 99 others); Thu, 15 Feb 2018 12:52:46 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:55028 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164213AbeBOPaY (ORCPT ); Thu, 15 Feb 2018 10:30:24 -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 5149C10B6; Thu, 15 Feb 2018 15:30:23 +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.14 021/195] media: hdpvr: Fix an error handling path in hdpvr_probe() Date: Thu, 15 Feb 2018 16:15:12 +0100 Message-Id: <20180215151706.815224871@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@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.14-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 @@ -292,7 +292,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); @@ -301,7 +301,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); @@ -339,13 +339,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); @@ -353,7 +353,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); @@ -361,7 +361,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); @@ -394,13 +394,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; }