Received: by 10.223.185.116 with SMTP id b49csp2253999wrg; Thu, 15 Feb 2018 08:49:20 -0800 (PST) X-Google-Smtp-Source: AH8x225Ep8XcFYr3szZe3QEhFLmpBcc0Z2RZfh76DLdzCRbziRBh4mkC0RQv/ytcA2e5UB/fL9G4 X-Received: by 2002:a17:902:9306:: with SMTP id bc6-v6mr3063922plb.29.1518713360100; Thu, 15 Feb 2018 08:49:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518713360; cv=none; d=google.com; s=arc-20160816; b=WmX/7z7AXjvECkuSdeICWSzzF9z0smgcul2NjIJSk8+tXXmhKx7ZeCHDvf0LCQzFXb tGqNYHluP35cwEPoSYaZeIUML64ieascXhJkI/5wvJkcsbRC068gAuC2k0fGYwvHTUP1 Zd9JvOpMERrQwKlA1bzHALusyyUL0G9h3vU47t2fecLrzeyMyJoyT/kFNVDVMAPQtOlc 58ymw/jeXwb0ufiHD/fFJ8APeLuReGZKuspmeZrQR2M3ZVLXWtsgynv6SfUzrtqlKoKm WXVzVVZrR5xahnOQxDYEz8PxMV9hf+dlZzX43A5QgAWukYfM92IXOSIQa2ZxXfJiJ49I YOkQ== 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=4kvIwlczhXd1n5eQ59C4N57afffNTzChGqKznnb5LFg=; b=tk1NqdvoOinTz7p8lHX55APpyIGUX3Q0kOjzitHuK9UQnA55I2trAjvpwrMKxOAktt Azb8ieES4tnZnYa/hfawsXWR8LHz5MudMXX+W3Di/KhkQQteos987lQ2RFEX/PBI3sh4 6X0YmjPKr8QC1dm0vHlMN8rn3NrIcmjOGCeP0m8O6Y40IirhdgmXeUIfJCLTlCp6d0iD VFe6P5XNmGblgXMgW+IEe5BqF/3WiF9k5AUpudnv+jgfr2N4Q4g4exTpDr65x9zmBiOO jpQ0R2IXTsf2EJdHm/703CZqbwu1xkqA5dSo24v3Mrxmzm7e/Rzgd7e2Q1EycBjKMiR0 k9Lg== 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 f15-v6si3075532plr.336.2018.02.15.08.49.05; Thu, 15 Feb 2018 08:49:20 -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 S1426454AbeBOQrZ (ORCPT + 99 others); Thu, 15 Feb 2018 11:47:25 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:60238 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423802AbeBOPku (ORCPT ); Thu, 15 Feb 2018 10:40:50 -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 8664D116B; Thu, 15 Feb 2018 15:40:49 +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.15 014/202] media: hdpvr: Fix an error handling path in hdpvr_probe() Date: Thu, 15 Feb 2018 16:15:14 +0100 Message-Id: <20180215151713.581534915@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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; }