From patchwork Wed Oct 19 08:29:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp223555wrs; Wed, 19 Oct 2022 02:37:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5cdH2K9MLnC7RwfYQqcVcVGW31Z+TauGdENUrj0aZr2tE7A7/n2Rw7k794wxOPjN74MVzW X-Received: by 2002:a17:907:320a:b0:741:72ee:8f3 with SMTP id xg10-20020a170907320a00b0074172ee08f3mr6010198ejb.168.1666172268718; Wed, 19 Oct 2022 02:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172268; cv=none; d=google.com; s=arc-20160816; b=mv3AzChFVrH3jY7bIhvoErJ+bggFs4Cml4wBHtOgE6rIfrgIg8PopAbfAvAF6XYfP3 Aad2Nu23j/jU115vH1deyURbFZcHpPJ2Hzruj2z6MhF2Dgs5N9wPGEEmVcim0UzE8y/X /bEdV/RMf7dKaJt7pG6q6AVqnY+VoNI4h6+KBqskIxUP/qumoeAnMdr4ok3HaVyGVGEb q5ibw9Fz03FNXfsPhym7wlQx6cxWhvYNeQbaJWgQzyNhSQn6k0AjkeQnPxFRBej1WCYQ 5bs3eP7miy3ICSgvGKI0/GweMbvREbJb0feJ5YA4JCToKXFOSywebtxljAybW2oJ8X6G UN2Q== 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=YNz7NnOxHKZUBORmijhyZdm3/Uh52RVNGTGa7VDwnkY=; b=lRD6vKaT7vRqhMnDunWjuQoys23LjPtWd5bbGGJcVvKvMkpZDBtQ6dMRWS7Vsgx/Yn akad6Hx8PayocmIAwnPyV1Y+bUr8ySUpGD7S5KkfTD0Gc43p5p9eWdw2pdGNxH+UqIVq 5uv0T3Wob8G2J7GKDEggOG5EmOIf5mvuJOLlFlGp8RdJ3CSDpBMVl8SghUVAYcsqffBz EujVLM37jjniLfZ687g3p0Zk9AbiKf8n1Lmy3UYyVTVdq9vo/U9TxgUgtlxNdikpyJkk 39yDDqAS4eKaYjV3gGQq1zcyH46km0h4TUGxYAtmFR7zeoun8A8phlaR7AWxGIocVTba GAUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ifqvi3Te; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u19-20020a17090617d300b00711da52c6e4si12357955eje.309.2022.10.19.02.37.23; Wed, 19 Oct 2022 02:37:48 -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=ifqvi3Te; 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 S233444AbiJSJW1 (ORCPT + 99 others); Wed, 19 Oct 2022 05:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233420AbiJSJVZ (ORCPT ); Wed, 19 Oct 2022 05:21:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D4D3C16F; Wed, 19 Oct 2022 02:09:52 -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 F143261807; Wed, 19 Oct 2022 09:01:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12F0EC433D6; Wed, 19 Oct 2022 09:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170088; bh=9IY8itcj0UntKkJNFI/Iu3RvzWtyhrIob2EbC+YLLxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ifqvi3Te3cGp3CQx6+NZ1Oao+aiG4jhHPvNmy7U44XpeLQIZnmRkgSbuKc1Wg7AW6 IBProP9Uc5CWOe9o+CEz98Pq3P0eYcxnrzzle1AH0Ec8maYyDuVtB5a0NH7ASMLV7/ ubcu2u7QzaIF+hIk3iPE41blr57xEyU2Jkoy11I0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+bb25f85e5aa482864dc0@syzkaller.appspotmail.com, Dongliang Mu , Tommaso Merciai , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 6.0 486/862] media: airspy: fix memory leak in airspy probe Date: Wed, 19 Oct 2022 10:29:33 +0200 Message-Id: <20221019083311.448540730@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747108252928304231?= X-GMAIL-MSGID: =?utf-8?q?1747108252928304231?= From: Dongliang Mu [ Upstream commit 23bc5eb55f8c9607965c20d9ddcc13cb1ae59568 ] The commit ca9dc8d06ab6 ("media: airspy: respect the DMA coherency rules") moves variable buf from stack to heap, however, it only frees buf in the error handling code, missing deallocation in the success path. Fix this by freeing buf in the success path since this variable does not have any references in other code. Fixes: ca9dc8d06ab6 ("media: airspy: respect the DMA coherency rules") Reported-by: syzbot+bb25f85e5aa482864dc0@syzkaller.appspotmail.com Signed-off-by: Dongliang Mu Reviewed-by: Tommaso Merciai Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/airspy/airspy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c index 240a7cc56777..7b1c40132555 100644 --- a/drivers/media/usb/airspy/airspy.c +++ b/drivers/media/usb/airspy/airspy.c @@ -1070,6 +1070,10 @@ static int airspy_probe(struct usb_interface *intf, ret); goto err_free_controls; } + + /* Free buf if success*/ + kfree(buf); + dev_info(s->dev, "Registered as %s\n", video_device_node_name(&s->vdev)); dev_notice(s->dev, "SDR API is still slightly experimental and functionality changes may follow\n");