Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1982485rwe; Fri, 2 Sep 2022 06:59:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR5/s3uR7VL/GxSAws9Nlntp99/+U/XsXes3LSrcizhgPNcFiQ0ZlLFWDLAQOJCeQNDbnZT3 X-Received: by 2002:a17:907:7284:b0:731:82a3:16e3 with SMTP id dt4-20020a170907728400b0073182a316e3mr27373255ejc.30.1662127159512; Fri, 02 Sep 2022 06:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662127159; cv=none; d=google.com; s=arc-20160816; b=Yga3wT3FezgEv8Bj8vz1vZfTUvMtoEZGUIEarIbuz+TaGIepdvKl8KQDJiluCMgiMO 9+duA8bWp/j4fre4x+qXI4SDuMc2K7XtoFMF/RFlA4SQ3uLN18zGv7zXOPC7BavsExFY gE16mqE4+6f4dQze2Ib2zFetB/+owXxn+g3qOzPAb2+/GoX9nTufTk3tTpkBlj7a/PtE uBYUdZMJhC4OFj/epmzmDC2SYIz0LdEfOXuohtPQlb50CP2f35njSWDXn6gsXsMiLABq xq1fUvfYtG2YavBGHl6xMXz0+rFEODfv9hW7frFkNI/yE4XyV6dN2oNNDfOBVKBJED9B IA0w== 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=6yB5dzJYuDM2bQNtmRERDpBlMIMtnD36720qXpMeNnk=; b=NNM5Bv+ujOMNTNJQ40iTyXfJVJ8+x/X9RNoyTLgHABzC+GbW67j0M2YoHyFyvNujjA hmglSk/DxrtVOg6Rhby/Y6FAlz5tcDsQXhgbIKifFZ2tMYkOt3mdI3z3a0PR1EcWEU+d 5zfAxSIUIchD9xSGpbZQBv+VP5D7UWaxwgJxgBFiWJJdYTm5FndPkqZ92yyqV3mizu// RNzzXDlMG1VhQKGYZXZTP0c+X6glJ8EjuHuDyUekxhSx3kz4WXk9HGu88Mp4qRtJbxwc JgQNzn1tEtbOaaPQyddmNCTit6dj0mEDHG1VnBKSiKBKH7DL3WkbJB/9BwH1GZeelrz+ 91uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xP5Rsd4f; 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 dn17-20020a17090794d100b0073d68cb42f0si1936931ejc.717.2022.09.02.06.58.53; Fri, 02 Sep 2022 06:59:19 -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=xP5Rsd4f; 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 S236037AbiIBNiz (ORCPT + 99 others); Fri, 2 Sep 2022 09:38:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237542AbiIBNh7 (ORCPT ); Fri, 2 Sep 2022 09:37:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B2A0125B81; Fri, 2 Sep 2022 06:16:32 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9E114621E3; Fri, 2 Sep 2022 12:34:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C9A9C433D7; Fri, 2 Sep 2022 12:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662122094; bh=xIwGVScQaB9wNQuwUy6UEhNULReYG68Iz9QNMVFlI5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xP5Rsd4f5bnyctrj7SsA85/GUiaAxiOlRmvPwjWys6D5iqvZunNrM6JQklIXfOyeu n6CoXy1hqnY8ZWy2KM+efzfN+/slaa5ugqJR3gAZJXQ0NDA4TJbKrKWIj+HrqK7oDB Ror4lL1ripmBGZ2Ad9Ky1YClriA70qygx5LN3xUs= 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 5.19 11/72] media: pvrusb2: fix memory leak in pvr_probe Date: Fri, 2 Sep 2022 14:18:47 +0200 Message-Id: <20220902121405.169501601@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121404.772492078@linuxfoundation.org> References: <20220902121404.772492078@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 @@ -2610,6 +2610,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);