Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp543979pxj; Thu, 20 May 2021 15:49:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxH5ndzkJz1fvrbgOlY2Haoz7eBT9A6QE4Nr9tse6tXuMABcoYw+nahr2GFbyXe+o5JMSQb X-Received: by 2002:aa7:db93:: with SMTP id u19mr7366633edt.227.1621550960968; Thu, 20 May 2021 15:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621550960; cv=none; d=google.com; s=arc-20160816; b=blif/FxHCENtze8AcqoFQ0mWOfNSkwRJMdybeGdXNmM1CDHnPgqhcOR6qM1ibQqVx3 fj7fa/IgYvS0jqT5y/qpkasINAIklei0oV2Lr/QWZl4psGpyt1h+q3733umAkR9JZ8sG bPceU++B0qAvlamplD3BFImxczRL/l824Z8SIV4oHWBvFjeE7LfJEk+L6iBHV+F0KpeY 6ACQaT9jRGnZz3oWrpHelqYYuMuJc8FY567yJ2reK/aRPzj2ziyyb1gz4hx3vLkzNqvZ GKJZptTlxWTDYj4EtzY3j6u2DvvVtb7xJBItRus4mXmRo7FlmR3e13feqUyxbiL22qFF GUzg== 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=zou0AspXx0uMDZ42CpvxrBdWxOlXFXaQlTNpDBRnVPM=; b=xrhOvQ/XD4Erlva94dJ5qy135NngGhUwH1A2YzLbNa8LFkVAbQoGZavqWSQeNSWnp0 G4sqtcbVVulxzfFolMoyxR/SvzXs0k44l5FBxlVp4pS3kruInICZHOnKlDGlnlN/sxH7 j1yeDLp+bVnSHW3ilxuNN3mL5AUrKuuUH4pr5JYCXSudF/WCPBeMa/bJdWbBwxkoP9rl MyqFP5awIIWUyND5BYVcdnXvLluwrKdpmO3fCsdOeofGQx6tZY5vbx8y6/u/ylQrCQkZ WgIO3zrAm0sG75O8LevPggIJhw/zKd75bOaUNwvHqoEpkyQZx1DeBAGCRCvQ66f508ka ZUGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k5a8z10V; 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 p14si3498102ejx.375.2021.05.20.15.48.57; Thu, 20 May 2021 15:49:20 -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=k5a8z10V; 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 S239237AbhETLHv (ORCPT + 99 others); Thu, 20 May 2021 07:07:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:49212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238542AbhETKtm (ORCPT ); Thu, 20 May 2021 06:49:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CAABA61CBC; Thu, 20 May 2021 09:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504745; bh=tjkIxn5V8+0BzLdtAIO2twJtqa+6KImAIg9oC+bPsrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k5a8z10VjsapXPvTs2meaHNSdXuTGFT+q+lxr+3V/10Rwiqm2PEmJKUuf6twvv8KS XEE9GTRVHOL5JjsaT4osvWzKD2Z6/NkE6T641ipvRe66/ifuLfqXzhtHtXBgDHFYb3 7oKeuHTIvyV21Ls+uQJ4jeexBCpjR2gtxVZeb6F4= 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.9 061/240] media: dvbdev: Fix memory leak in dvb_media_device_free() Date: Thu, 20 May 2021 11:20:53 +0200 Message-Id: <20210520092110.731561447@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@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 @@ -216,6 +216,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;