Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1043797pxu; Fri, 16 Oct 2020 02:18:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcJWKFelpk1mS3FCnofZW+4EFGtFTlz4IcOV45jM3l59cFnaT0kly2z3D7MArEq3AemAv4 X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr2693725ejf.11.1602839927541; Fri, 16 Oct 2020 02:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602839927; cv=none; d=google.com; s=arc-20160816; b=d4yFBXIVkiMWMm6kfgfEiVHl5woDwpuUMuQRjgppFz1QdLt2VmNf6nDoZO3Gtwizga YbPV0/4Z8KP/PTQ8qf17tp4K9yPa3l0Bps4VEgap05VuobWiplfEijcwqjNBJnnakAaf DDsEdcz0AQPg/DYg6zwGQPk3urDxE0bEWHz2i0tXNfth4YokEPLFAKDh/mQKr5UkdQsD Vvux4K5MkIK82cOn5ZQtBDAdLIq5gpeUh9tZZJV9SUU8jwylPFgAQlQNsAxjacnIcl/D ZlSXrILWQ4xLOHxxULbA5ZQ+fyh8Bi+ja2DW2MhtwElkiv9ctRYRM4mdbLfXD3BZ8O8v N8hQ== 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=NuVeEU0u/uNBwtO+k7TADwv03G+kzKnJnK/kOE3rWaA=; b=t0T1D/qJHBaLwznYmI6mQTyBnxbziJcYTUZDFBjWbetkctuxtKOjB8SzsarUxJ3fhp fpVYj01YWdmZzGJNPmwyRAbI3OA1tCGeDnxudU6EQkgelKNAjQWDqFefTm8HWwWDiV6c llulb95KG1ah5SqJixXacwP3oX/gQ8OhC0LVCAxXCZCZKO5LD9c4mfKejNyyoOwFAB4P 4Xm/DlJ/o1yKDKGXKscxyS6eNFHGADyWo7UCjzenOCpNWQOVk25VhVVFaBsezOCqlXJh PGtbtCjwX5is7x7IvzUwpoyXwE7CCgrnaqQKIpbjiCcAexoahKeL8Zh9p34j8dSx9Pxx 48dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zsvaPTdN; 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 jr8si1488076ejb.304.2020.10.16.02.18.25; Fri, 16 Oct 2020 02:18:47 -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=zsvaPTdN; 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 S2406320AbgJPJQH (ORCPT + 99 others); Fri, 16 Oct 2020 05:16:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:37424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394602AbgJPJIu (ORCPT ); Fri, 16 Oct 2020 05:08:50 -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 0FC1321582; Fri, 16 Oct 2020 09:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602839318; bh=rCuKaO0ItDgcez7vR2S0pKoYWlZRDIP/DdBssTSD7QY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zsvaPTdNWgz9WTRFmwDPUN/sdgOp/MJ89WyJ6e4H9m3QJM/yMp0Gc6vs32o+dKwvi Oe/s7JA30jqDVz6jOjOT1n8q4MnkANN377Csi9AeDJUIN4wXO5jP85OBXUNPMTQ3Gh WIkgdfhicD+m+JmtOPWz23HcCD+rqAHAAoWVJMjA= 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.14 08/18] media: usbtv: Fix refcounting mixup Date: Fri, 16 Oct 2020 11:07:18 +0200 Message-Id: <20201016090437.694246818@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201016090437.265805669@linuxfoundation.org> References: <20201016090437.265805669@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 @@ -113,7 +113,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: