Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp432531pxj; Thu, 20 May 2021 12:45:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv5pQBnMQ4s/pHvO65wZ+B0/MuAMM6wzWCaPjj10E7KpkdQav+cFjlV9rJhSj2NV+wJE/e X-Received: by 2002:a05:6402:5174:: with SMTP id d20mr6866278ede.248.1621539924495; Thu, 20 May 2021 12:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621539924; cv=none; d=google.com; s=arc-20160816; b=EHVzkdTSRILulI66fMg7ubuwyCOhZqS0AiJFxAiujMt8LrnxOxNdTSLymTlmznAvYL 3WufGvJV1hvqgat32sOxtRZJihYhcQnaHnb5+r/mCYw5A9ZP8R+MdtdXmTG2xU+Vi8NI tNYvh1XxC17e5PD68EyzZY3DyFdPloWQJjzHEmgFHsWptL8skcEpTLEVC63AMgFsN9pt T9KZ6x7j6F0gCFOh9bin5pNiTM8IapWCIW910zBx5ZFR+7ExF6lLt7MDDnS0wxOpQto6 JCPZZ86i91gLLi5Fbbz4tFRHPs2Bs4qhkjM74aliZRIgAoGB2DbLmzg8/38qSA41i7jG TG/Q== 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=TBc1stRet5OsYLbeKDYOyGH/ENMmo6S+LpIxcsbGMOo=; b=lEL+0HvufrjP0D2W9QGZUrCpm5RmNSUAztGeq1eVybzQBF/jueP7SnyfhvFBVPwlcM Uz1s9CCetIUQacIk+xTbEzDzNE3SATTeKWCtMaTS/aEJshzdKWeyLP/Dk8wafGJtcy/E yrK+AZt8A8vljXGAjUrdo5Gq/NdOBHjxT9K4gQq+NESQm3p0D8zE4OJ9EtiRE89w5CvT Gc7MjAIz6BMS1fibwMtgLq5MNPdOK/5/3Zll/1JjD/QfRYTwSiMqzhu+EHRLGFrt1LP6 yGIYP1d7St2gwSfb5MFIaIzwf/CFsQSIXd+UMKx154f5x0ytfsA3LSbP4b363YMGd5/Q lp6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sU1nw1eB; 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 u19si3320058edo.180.2021.05.20.12.44.48; Thu, 20 May 2021 12:45:24 -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=sU1nw1eB; 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 S238151AbhETKja (ORCPT + 99 others); Thu, 20 May 2021 06:39:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:55788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236799AbhETKYb (ORCPT ); Thu, 20 May 2021 06:24:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 438E96146D; Thu, 20 May 2021 09:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504164; bh=uh11iCPGGtC1rPCM0dfRNuyJonGJ/oC7OhpilX93Mqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sU1nw1eBffFWsu1CNeOGVpzV1v2w7qLPX3/Wm96dK6/y+NOeuv8Mw7Qs1HL96mewq rezIuxeCYzX/tzf8oakkjhrCaeUUtyh4UC3ve8geKJ3/KFacWCFPR+agleU2PmFL/+ +cMrFWzcaj63Wwy+7EcTgkfUDqYk1pX3Ec7eFdXg= 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.14 094/323] media: dvbdev: Fix memory leak in dvb_media_device_free() Date: Thu, 20 May 2021 11:19:46 +0200 Message-Id: <20210520092123.322986966@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -218,6 +218,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;