Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11813425pjo; Thu, 2 Jan 2020 14:43:59 -0800 (PST) X-Google-Smtp-Source: APXvYqxoAKE5DjJZcWNL7Oye2jMu0koA7EgxzSWapSKeoRVKIpkun8sIDoFQodfOSrmd76R7RPwf X-Received: by 2002:a05:6830:3014:: with SMTP id a20mr69568224otn.350.1578005039664; Thu, 02 Jan 2020 14:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005039; cv=none; d=google.com; s=arc-20160816; b=YURrLnD4GwM3q/iSUihDLI0geFjC71O9zDLQcGKVlIJ+/gzF8e5gekTNqoPUP42/1a lpcO1MX1S17huVjo/3GGvgWiIu+4HC9omtpOJbfkRZ1eAQxzy7DaZEDzzZ77NVhFiRZe HtPid9NaZQI/jkbZuRimNsSE1QDgQRJM1NkhZBwGfrsFUrfnvEEBqUBVnF8cNvebhJxb kELXA+9Pyqaoe5ZW8LTS9CubNZyP0TinjOlCC/aI+9NnuzX2F79z+rd8JebaA7UonGeF kc2vgIsDCMb1V8lfWdcz2JPSoaLDLXS4Rru3mucVgrfuiMDEADcGNbtBHcTQ7SnqzMv9 LSgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G3r5oPQJqKpQ90JuXktIHijlLih64EfComMqoe+dKxI=; b=K3WpAbS9Dm1LZgs6PEkKUlqP3K01NE4UD0BFAihg15wvVLKYMSWtU46UXeUq0feJbp 5mpiUiaQwbwQ5nXUyYdDbj0OQw9noP14yc/qYduUJXlHyQ4oaGJ1NFF4uFWs5QY6YALv G/4KJo0aknGclQID6y7QK36wwafa1Uu3ANr85eARO0/9CdpfIKdSQLneXUi+1BdGUl7G zQl8rdnlnUK8DL0/czUEOJJe+JDOcB3ioBNuQr/wsHooKJtfhGWKkfM4zdruo4O81NDA DaRGbFqJZgUw9sCItcwwKMhS9pDnlek7sRzkuq3f+NmwprjlWnPV5UXTcTI/Lf/Qu9bB gmuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ex3VTBAE; 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 j3si22927745otn.154.2020.01.02.14.43.48; Thu, 02 Jan 2020 14:43:59 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ex3VTBAE; 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 S1731197AbgABWmh (ORCPT + 99 others); Thu, 2 Jan 2020 17:42:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:45718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730658AbgABWfn (ORCPT ); Thu, 2 Jan 2020 17:35:43 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 6877422314; Thu, 2 Jan 2020 22:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004542; bh=PomQWtk5Aqk0M4fjZ4wvcJhhd57S9AsXiAXyEeCOMK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ex3VTBAEV/HEPNJzjLU70SFDn6k6+d6ijjGUqYixf6F+UVwmJvh3jgbTMm1rnCPlC uX/7vO/IUR3PsgLVIFdueparq/N/MUoOYqSFZT7FU+n+3b5fknWMT+X/VepHM1VTGC LX8XAiN8ryJuoaaN8JAMG2ZZ4ZQCrgJhzT32z/qE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Isely , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.4 050/137] media: pvrusb2: Fix oops on tear-down when radio support is not present Date: Thu, 2 Jan 2020 23:07:03 +0100 Message-Id: <20200102220553.306302974@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Isely [ Upstream commit 7f404ae9cf2a285f73b3c18ab9303d54b7a3d8e1 ] In some device configurations there's no radio or radio support in the driver. That's OK, as the driver sets itself up accordingly. However on tear-down in these caes it's still trying to tear down radio related context when there isn't anything there, leading to dereferences through a null pointer and chaos follows. How this bug survived unfixed for 11 years in the pvrusb2 driver is a mystery to me. [hverkuil: fix two checkpatch warnings] Signed-off-by: Mike Isely Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index 1c5f85bf7ed4..2d6195e9a195 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c @@ -886,8 +886,12 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp) pvr2_v4l2_dev_disassociate_parent(vp->dev_video); pvr2_v4l2_dev_disassociate_parent(vp->dev_radio); if (!list_empty(&vp->dev_video->devbase.fh_list) || - !list_empty(&vp->dev_radio->devbase.fh_list)) + (vp->dev_radio && + !list_empty(&vp->dev_radio->devbase.fh_list))) { + pvr2_trace(PVR2_TRACE_STRUCT, + "pvr2_v4l2 internal_check exit-empty id=%p", vp); return; + } pvr2_v4l2_destroy_no_lock(vp); } @@ -961,7 +965,8 @@ static int pvr2_v4l2_release(struct file *file) kfree(fhp); if (vp->channel.mc_head->disconnect_flag && list_empty(&vp->dev_video->devbase.fh_list) && - list_empty(&vp->dev_radio->devbase.fh_list)) { + (!vp->dev_radio || + list_empty(&vp->dev_radio->devbase.fh_list))) { pvr2_v4l2_destroy_no_lock(vp); } return 0; -- 2.20.1