Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2024166rwe; Fri, 2 Sep 2022 07:30:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR59EYF4y4hSTy5ChT/Gfj91pI9z/6fMAuDXbDTnQbCooq7AmYBkgpKce5NtembMYHcV+dkR X-Received: by 2002:a05:6402:5242:b0:448:6849:7e1e with SMTP id t2-20020a056402524200b0044868497e1emr21778344edd.137.1662129003661; Fri, 02 Sep 2022 07:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129003; cv=none; d=google.com; s=arc-20160816; b=T+8D2IpqrCb1d1nM2BGjAMYXifFOy4ro8M7LITjEAXV0ug6c3k891ii/oQU/N0YVaD 5UMuNiNFLVqAbA5c3wTuFGyKfgyUPXNuYy/eyOPgo+vP2I82B32DDdVnUym7NbH92f3W zL8PNwsyRUwp0jnqu+dPd7iyUwC1nUlfqiXrc1ssDfrDKJ2vLR8MrY1kXVv8zAxmtk+W V3Mw5SPs+FxwUJElJ7XCjIVmJOygnHB3lI25uSJEayHVMgt+cprilj3GNoTlkb9ITb09 iAhUySRf3n+41Ttr3MoMhrQmn/zrQEpS2p8BLVd4YgDr7bMV9gmKxFlpUdrHks8sZToh aMAg== 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=VjbeyaMjUuqSXJ3OU4G8sXKm96iHKYDsV59Ueu3uGnw=; b=j+pPrFkAWOIjHgEGyBR8q3bbJvhEN57tS3fitWg6tAcNqpQ9eMXrgBCD0cB9AaXyPj kbw/GA5vGpjgOu1qAv2RWatYZlHkcBgktf6xJxN9KJjTl8H5SeGAfQzjn4q8zIgfo1Q9 2bqunE8pylPaS0qHx8tdYERcrRo01znigxeIE3bLU7BJqmK57bYexEHgCo+CqoxmUlwb KqNCEzuKO4+2NewbjAp3dR0CiX5c54jlXGJgz1WLen4k6nHkPfCt7CFkpxSXlZ584eCV xQCWAWXvU/6VxxHAR9nZgET57KBg4pG/Qsp9E0A3kAAKLAAp9TP2PphtixpW2CZO1u1g HvcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bNSsLdOA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr30-20020a1709073f9e00b0073d751c96adsi2114431ejc.1000.2022.09.02.07.29.37; Fri, 02 Sep 2022 07:30:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bNSsLdOA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236227AbiIBMXm (ORCPT + 99 others); Fri, 2 Sep 2022 08:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236195AbiIBMWi (ORCPT ); Fri, 2 Sep 2022 08:22:38 -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 77AE2D572E; Fri, 2 Sep 2022 05:21:47 -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 A5350B82A98; Fri, 2 Sep 2022 12:21:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3CE5C4314E; Fri, 2 Sep 2022 12:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121294; bh=LXFuGh52Ih6ViWxD28QZenZPx37roNq6XBQnL5p6ONg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNSsLdOAkcOrJF2jS0/J8H8nmLSzvYtJs016Egh1bn/cmNQtT9lz2IZSKmOuqQe8Q o55az21jHwv41ZZEgmrXbCd0Olna3tEY+NvopWpHZD878CO6gyCMrPRL6TOh5RPcpc 1rZbJMEVtXq14TnQh2trjn72M0k1Ed2xZK7H6siw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+77b432d57c4791183ed4@syzkaller.appspotmail.com, Dongliang Mu , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.9 23/31] media: pvrusb2: fix memory leak in pvr_probe Date: Fri, 2 Sep 2022 14:18:49 +0200 Message-Id: <20220902121357.611984352@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121356.732130937@linuxfoundation.org> References: <20220902121356.732130937@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dongliang Mu commit 945a9a8e448b65bec055d37eba58f711b39f66f0 upstream. 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: Greg Kroah-Hartman --- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c @@ -2656,6 +2656,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct 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);