Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1040020pxu; Fri, 16 Oct 2020 02:11:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmJDVU2f7/Twwy7wPr09MQ1oZePNdgK4v8xH9vRCVCtRl0/5ddBJreie0rta6vvCIlYHjm X-Received: by 2002:a17:906:5593:: with SMTP id y19mr2592184ejp.369.1602839489699; Fri, 16 Oct 2020 02:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602839489; cv=none; d=google.com; s=arc-20160816; b=MM61sAZwU9Uo03ww1AORW2483m4oF1B6ALEIVpq+Yyq5tl+h63NlvF4PmHsJCEMT2f S9EjUs3eW1Pbdo+t5Dmjodr470bv2mOGdN5/PQxifYulk1XLemTk3GtPo9yhCI9auW75 qD+qCrNSjQeheBNnoZDopnOrOuODMJKOMmPMW4mYcp4+5M4nGTu/rgG+j1QFMl0irfGB gWr603fwlR3cJI0XjfUUrDmVEOMUGVB4qSnO8gBOQgJZ4TrnS2WefJ8Bs3YXQwucScxy ZBKyVqB5xZCE23vBiDkw8TL0Qd3+gVDyvbYi6TaNb72lUflkE0eb635Z/nE5EemxamS/ cHIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QOyfaqYmEW8uR0cbjLD8nEAeLTQ/EJ5jBeP9H/gg9Ss=; b=WkaJKKsrEqpLeG+nFO5bNmnIlc7uFF6opT0gf5TGT4NowehslkYT8uO6cz4xEVpsll FjA06vKNBos+A0+5OOmp+JVP+JSnGP0q1hxLqPxoBquBkMVfHy1mJZJ+5CWofPyqyvpq kfejCJziZhJ9EjQAFwFEgXSDGpdJa3690PcXI5KeD7ZeBnNGTyiva2mKmQTnOqN2VKIi MYHJWOet0oX4QTr0mlwyZX2vuIoKHGn6iCbJauLWxYbAMCZg+By1SQ8nA3+Cyky4F8EZ dx7A9nGalKOdOuB0lEBKM+jp7E6LPSaXDWxBpYo4mApm1oaUvG41DvcSPZikYzmTzDP6 3aHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HWB3Ewaf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si1307575ejj.231.2020.10.16.02.11.05; Fri, 16 Oct 2020 02:11:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HWB3Ewaf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405477AbgJPJIW (ORCPT + 99 others); Fri, 16 Oct 2020 05:08:22 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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: