Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp305009pxj; Thu, 20 May 2021 09:42:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfU0DtR1eFZKMAa4D2Dun1sAl5sCY0c+Y/ZSV5YFldtUfPqkbpI7WPJIDt1gViShI5dLXo X-Received: by 2002:a17:907:3e23:: with SMTP id hp35mr5616141ejc.437.1621528964827; Thu, 20 May 2021 09:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621528964; cv=none; d=google.com; s=arc-20160816; b=W6FJQpwNzCZkLXJzVHNpi6aBWtL4TJXNH0WrREWFI6bK49gfceWNdjqpU/9iqGvjFQ mFgyyt4vVj14te2gq3UttZgvOLurcq+PMLQy8sJCBg7gudTNszbol4vlgPBG9Di1bU6B 8lxFc217tv1CEMMfr4Um1zKR6BDA2kwJzYvxn4v0yb4npegraZbmTu561iOcVMQoKxn1 d42V5YOgHYXFsmJ1wZ5mY8lenjTFN9ouRtXfXqroQPWp9GIhKTCzy6zMFPlU+2QH06rq wfB+hq2Budpac6yxEZ1wyL0oxlg6/SATK96DJgKcM9tlB6s6E40dlDgeLohHVYxQ3EbD f93Q== 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=jBqxMd/LcJTtKC8/aRjCyge/btKiy18ZBIf7QL4QpxE=; b=HzWFTmJ31F0fWi6lHegziQTxwZrh9dfzZ/QKbUuParxYKD1ltCVqWx76Q3Gukflx33 7y3sriHTFf8m/oCbFHbSvazpVXDKPRvOeq1+gbZuL/ZdA0iPznvRCY1Ob4fNPbOGaRa3 nF8rx90X16l/mw15EXJ6CRjUG4QQGOtl5EGrnEnJULnkUrG5fU0OKsFL6RhynH64UkaR ZoXQJAcIB6QAna6yeKzHgXHiDCKpfrvydOU8HG6T//AEWxozIf6W/RrmLLQr0Izaig2z zgr+h06Mjuit2QoXobKGpSxqOG+G6WSYn7f3pWxCLwsMVNmExJROGHbE4Zbyn/3qou94 MYJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="m6YruzW/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id op26si3442840ejb.703.2021.05.20.09.42.19; Thu, 20 May 2021 09:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="m6YruzW/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233318AbhETJra (ORCPT + 99 others); Thu, 20 May 2021 05:47:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:46030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233920AbhETJoh (ORCPT ); Thu, 20 May 2021 05:44:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F10676144E; Thu, 20 May 2021 09:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503199; bh=L4Z/lavsAkh015cOpILC8zaDta2Yugo6DqHJ9fBvJK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m6YruzW/B3rJ6tRbOJgKifzhpcUUsawGRBeXMsH1ZDMfzZEANSO1cJWqLQ/t7c+yI 9PgxSXmsvUVCZBJYU2Wc1wNoDlgViTsFyg+bNYI/UsViKEh+DISCiV5xVK+QKJxh3q tQDzlaLEEdYBBLrNUglO20DOw/b72vAUA7O0N7xw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+7f09440acc069a0d38ac@syzkaller.appspotmail.com, Peilin Ye , Mauro Carvalho Chehab Subject: [PATCH 4.19 106/425] media: dvbdev: Fix memory leak in dvb_media_device_free() Date: Thu, 20 May 2021 11:17:55 +0200 Message-Id: <20210520092134.940765597@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peilin Ye commit bf9a40ae8d722f281a2721779595d6df1c33a0bf upstream. dvb_media_device_free() is leaking memory. Free `dvbdev->adapter->conn` before setting it to NULL, as documented in include/media/media-device.h: "The media_entity instance itself must be freed explicitly by the driver if required." Link: https://syzkaller.appspot.com/bug?id=9bbe4b842c98f0ed05c5eed77a226e9de33bf298 Link: https://lore.kernel.org/linux-media/20201211083039.521617-1-yepeilin.cs@gmail.com Cc: stable@vger.kernel.org Fixes: 0230d60e4661 ("[media] dvbdev: Add RF connector if needed") Reported-by: syzbot+7f09440acc069a0d38ac@syzkaller.appspotmail.com Signed-off-by: Peilin Ye Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/dvb-core/dvbdev.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -241,6 +241,7 @@ static void dvb_media_device_free(struct if (dvbdev->adapter->conn) { media_device_unregister_entity(dvbdev->adapter->conn); + kfree(dvbdev->adapter->conn); dvbdev->adapter->conn = NULL; kfree(dvbdev->adapter->conn_pads); dvbdev->adapter->conn_pads = NULL;