From patchwork Fri Oct 16 09:07:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 290308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A894C433E7 for ; Fri, 16 Oct 2020 09:08:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 307B8212CC for ; Fri, 16 Oct 2020 09:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602839302; bh=UwulFHlFJ3R8+s9B41iyipr7l+h/hYROi9JkyECHeC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EtORdbskGP6GmfPH2wda/t6pIyiyRNvnzQ6xEHUqGeYEzKa+q02nN3DdBt8MXqTkY JqE6I6pxz1UuvaEPUNIyNoV1KmPcsjAwW6Hr5AfA0PjbwQyvu4v9LqEFmP21hoJWzQ u7EerwBVmm9TA4MUUozP5wXAJI3JkoHx3CpG3sLw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405473AbgJPJIV (ORCPT ); Fri, 16 Oct 2020 05:08:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:36530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405445AbgJPJIG (ORCPT ); Fri, 16 Oct 2020 05:08:06 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1AEBD20EDD; Fri, 16 Oct 2020 09:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602839285; bh=UwulFHlFJ3R8+s9B41iyipr7l+h/hYROi9JkyECHeC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HWB3EwafVpMJHswO2xKghFq3Ei89GoZDIMeKD/CIKNtMpuTLOEh2pIZMcpxxrxzy5 7OauNEk3ytEaZ91vHeiXokNZ89S8vMmeP5xItn3cC9yqbkYEz1ycc3TQW/0RHfR+IU 2CsYvuI588RxipxSx0EG8OfGA+tVjoXu9LIjFRQs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Ben Hutchings , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.9 08/16] media: usbtv: Fix refcounting mixup Date: Fri, 16 Oct 2020 11:07:12 +0200 Message-Id: <20201016090437.633348977@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201016090437.205626543@linuxfoundation.org> References: <20201016090437.205626543@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Oliver Neukum commit bf65f8aabdb37bc1a785884374e919477fe13e10 upstream. The premature free in the error path is blocked by V4L refcounting, not USB refcounting. Thanks to Ben Hutchings for review. [v2] corrected attributions Signed-off-by: Oliver Neukum Fixes: 50e704453553 ("media: usbtv: prevent double free in error case") CC: stable@vger.kernel.org Reported-by: Ben Hutchings Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/usbtv/usbtv-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/media/usb/usbtv/usbtv-core.c +++ b/drivers/media/usb/usbtv/usbtv-core.c @@ -110,7 +110,8 @@ static int usbtv_probe(struct usb_interf usbtv_audio_fail: /* we must not free at this point */ - usb_get_dev(usbtv->udev); + v4l2_device_get(&usbtv->v4l2_dev); + /* this will undo the v4l2_device_get() */ usbtv_video_free(usbtv); usbtv_video_fail: