From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 725EFC2BB43 for ; Thu, 11 Aug 2022 16:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238862AbiHKQhe (ORCPT ); Thu, 11 Aug 2022 12:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238972AbiHKQeO (ORCPT ); Thu, 11 Aug 2022 12:34:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED1EBC800; Thu, 11 Aug 2022 09:11:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 133F2B82164; Thu, 11 Aug 2022 16:11:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2CAEC433D7; Thu, 11 Aug 2022 16:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660234267; bh=CpN0KNYJD0OMkZVAALbZfviYNAkXvcgFT0Qp0T9RZo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iDS+j30VphnTzvXxolNxqGt7XdIreYnNTblTy42PD5uMULJg1h5blZGzfyjQcz1lZ Dphl7OBq4qrd9SUnWsD5NmyqHvDGZtlcQzKkCeFhFpB6R1vM4Zr+KO9y1DShTzgXYg NXhJehT+FRNmUaBNpJWaiTXonSLShBWTqJK0Pdu2iV5N7mi/GyzLBKxkSs+JpSkt2q WYqGAeICIsZ6IAXfFIpngctqYPL3WfM6+gA4bAIfwWlABnpXldicyJ99OVr29h6i9N UYu7l4bNiOY0k8XCc/ZRhjUWlGCvNKh9cqEKAEkTpG9nBeOYeszGleNx9trXuagkqE MhProqIftAFHg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dongliang Mu , syzbot+77b432d57c4791183ed4@syzkaller.appspotmail.com, Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , isely@pobox.com, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 06/14] media: pvrusb2: fix memory leak in pvr_probe Date: Thu, 11 Aug 2022 12:10:35 -0400 Message-Id: <20220811161050.1543183-6-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220811161050.1543183-1-sashal@kernel.org> References: <20220811161050.1543183-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dongliang Mu [ Upstream commit 945a9a8e448b65bec055d37eba58f711b39f66f0 ] The error handling code in pvr2_hdw_create forgets to unregister the v4l2 device. When pvr2_hdw_create returns back to pvr2_context_create, it calls pvr2_context_destroy to destroy context, but mp->hdw is NULL, which leads to that pvr2_hdw_destroy directly returns. Fix this by adding v4l2_device_unregister to decrease the refcount of usb interface. Reported-by: syzbot+77b432d57c4791183ed4@syzkaller.appspotmail.com Signed-off-by: Dongliang Mu Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index 4b0d44e25396..0abe50f1965a 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -2604,6 +2604,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, del_timer_sync(&hdw->encoder_run_timer); del_timer_sync(&hdw->encoder_wait_timer); flush_work(&hdw->workpoll); + v4l2_device_unregister(&hdw->v4l2_dev); usb_free_urb(hdw->ctl_read_urb); usb_free_urb(hdw->ctl_write_urb); kfree(hdw->ctl_read_buffer); -- 2.35.1