Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp184515rwb; Wed, 10 Aug 2022 22:39:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR5E1ZPfr6EqFx8y6rGSHGMLc9I/B/WXDbLuLS+fh3J+dn57Ifzx9O9UUCRSJJi2g3BxC/2z X-Received: by 2002:a05:6402:540f:b0:440:d9a4:aebf with SMTP id ev15-20020a056402540f00b00440d9a4aebfmr13379574edb.196.1660196379545; Wed, 10 Aug 2022 22:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660196379; cv=none; d=google.com; s=arc-20160816; b=tFnLBs+TuzzBQp9t1xVyRveu8d4PTQRUZklg6Zx3qUkyWizbDWRmEL1IUqUJQ6wU7p /RbdQpC1dFV2OQ9MXwSJ/VrFPIIGWBJAyCAbELeeA213sND9Iaem2UfyUsQnGVUvLsJu G2gC/km7vsvG4WNlnbbiGq9EFEtVICSZkw+VciwMLhQsfWrRdPtmHdoUeCgHLxTPUgit L9ZF5rKhN89zHBjzEIP75c+UziJiU5fwxCfSM+pHIghQ0H3J1nGhs1FI2Ft9St1L0CnE s8sOnuZ2fdc99/Iz/WlUSJ7874RPbc0vJmcUyObP+MAnTp1eEqZmGNpKFqNgoJtAy308 0EjA== 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 :message-id:date:subject:cc:to:from; bh=ntIKTgSG6/Vo0JoX3Ve4ClQu+p+smhm4t+vfEBS4B04=; b=TEeAzgSWtKtRzIK1sYlEJmB2agG04+lO+rL8S9E9oAuyvcvu4HgsVSA+0KOZ83XGTt cDskyuJCAXHpr0kJmaow9L3/tUpVELdHWbrxmYBut+o4TQQrUZ9H59wlrDTBpzC63Yqh tyipz5tWFLHGjItudbdh5JUprNW6S6ShA+MbMqnHd8gxstimUsVxuh7fDFBePskkqATx ag4Wyvb+TPSlaR6/2t5SlN0R+0DlosDIVT8RiQIB99RjuFXt0iI40PZ3fiUdEJRD9e6a 3uKa1x11XZewTomNUdGTznYJHQE7uAcEYDE7yAZban3LnivNE1fW7IP/gDgsoyn8GXHg bVQw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf20-20020a1709077f1400b007269661baf2si6111173ejc.475.2022.08.10.22.39.13; Wed, 10 Aug 2022 22:39:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233932AbiHKE7v (ORCPT + 99 others); Thu, 11 Aug 2022 00:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233459AbiHKE7u (ORCPT ); Thu, 11 Aug 2022 00:59:50 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B087CB58; Wed, 10 Aug 2022 21:59:47 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 27B4w4gc000522-27B4w4gf000522 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 Aug 2022 12:58:08 +0800 From: Dongliang Mu To: Antti Palosaari , Mauro Carvalho Chehab , Hans Verkuil , Oliver Neukum Cc: Dongliang Mu , syzbot+bb25f85e5aa482864dc0@syzkaller.appspotmail.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: airspy: fix memory leak in airspy probe Date: Thu, 11 Aug 2022 12:57:00 +0800 Message-Id: <20220811045701.31152-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 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 --- 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"); -- 2.35.1