Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp567026pxu; Fri, 11 Dec 2020 08:53:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyh4CBK4iaehXYSIrzRL+EYDDQYhshYFCBthelFcL1WFfOyxdeksIet2TfbduHos7CBsznl X-Received: by 2002:a05:6402:b88:: with SMTP id cf8mr13135873edb.140.1607705613832; Fri, 11 Dec 2020 08:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607705613; cv=none; d=google.com; s=arc-20160816; b=heVsxeKS0Ts+AnYo9sH5GY6quYdOU058qbVF0is7vGP0x5wY27T4bSn6K44fpslYSW nqXXzcCETqTHkzCNSbi/vBVuUUMBBXZpCO0j854p95AAewMY/A3L+AhTCNsQKzUxp5vK GL6nLZMFFqVMit+K7TbTqwvF/2Ef/NVYw0Fb2khbWbOtXNij0wwTvMeD3pp1uYqlD6p8 XEsoTAyN4ec2iADIJfOFnGtUWnw4sF1MYV1m0hyryBiGyNTooeqnb5AXDpQg3Y2bUpAp ISKW+vWFb3pI4tVrcKNy6ML3iQQiVaPR0E7O+13mAUhWednckL4F8+9wfy/y1uOlRPea kLCQ== 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:dkim-signature; bh=BvXfqmrNJagCH+GbSgfFYVoOHFPlLGvLrR6QFrYlfo0=; b=URVk6dbIBAWBsXbJtp3fVKsuE7+/CBq1oLSJjzzYGEWFOJdwFQKkBwXSAlhVGCVM8N oy8F3B9BTXXEfuDLBWIA1HqKLqoEd3wdDCMKLRp+Z8yWH5tvb0UKkgK/BLJP9Io+i/ZQ 4L2SI3/yJEd1MbpyK3Em0bBfVkzHe2E4GKIwJ1lrWIuEoCAycFn3sSIK8t1ehHT1y6Wr oRem8y+pQadBJY9TQO218pkoZ50J5T40H9vrfyCCJXMT9rpJ5WthgF9+WtvwY3rSv+XS MAfjnGFGiZT7MbwiLWMXnKuRmpT7Zs+uhKCMIvinm4YSmJCkE5ag1QUrHOs7qtdT3Ud5 VuJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JREI7iGf; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si4884937edj.405.2020.12.11.08.53.06; Fri, 11 Dec 2020 08:53:33 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=JREI7iGf; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730173AbgLKIb6 (ORCPT + 99 others); Fri, 11 Dec 2020 03:31:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728423AbgLKIbx (ORCPT ); Fri, 11 Dec 2020 03:31:53 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47A8C0613CF; Fri, 11 Dec 2020 00:31:12 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id l23so1971103pjg.1; Fri, 11 Dec 2020 00:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BvXfqmrNJagCH+GbSgfFYVoOHFPlLGvLrR6QFrYlfo0=; b=JREI7iGfFOa9A7qYLjV/3iCghgcy2ZGlfv2kndOL5KF3YExuqirtUbwP6dIyZgoGDW xEdsHJM4m3lLOOBBuyHeHmzJfeahQV8aU79qiUBmyh/XfunEzandeK5G3NUESt3AWFcD a3ezSMUd+nR4hOuPGZpjmPcOjFQCEE5g7xRh9Kp4CGmPYMDh8XXvH5YQcT1Lhcai3Y+4 E7IoAbLXCh+ZKqcc2Am5URYpCPMSQWDUJBpD+lZwnbO4zZD1nwmlUqkP8kWFWCvZ/jcp 2kyerygUYyukX490yhTeGKq7bs+4TmFxr4PYUBV7gvSe6zrBY93YjH+CHkmkZhhtPNf3 TeeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BvXfqmrNJagCH+GbSgfFYVoOHFPlLGvLrR6QFrYlfo0=; b=Suc5Qbo8Aner/rRZhx+qPI/RmHZCX2luVjUILGpnijHnegkj6c5jTkHn4Ze55H/HwV eY2jXN9TUMHiX3PalvkjfLXEL7MmWVHINO6nR/MIokkXBPo0gCQ+KUtV92tu2NBcZwR7 rCmKv3DXn6yZRkpnBJp3EAZOCkOu7ce+W2rlEtWHNRfhSgEhN+j/JtIb70ntqe0f+A8V cVFfNgdA1Bw9acuVmlv8KD0YxhOzJFqjTgLASeEror2L6Ikvshwqt7vIM9wxkEKqSF3f ByRMUb7G5aLIMgjDqrp+p60r27SgjwLr3Jm/kejc7DN5MtWCZeASNOaCYlztTwj8GdFh HARA== X-Gm-Message-State: AOAM533aKt+WgWYoS1/IJHkeYBzrbtWlg/IbZ66n6i1d4hIFni8bIKj5 5zYPDfo50DjfC6sDL8JT2A== X-Received: by 2002:a17:90b:8d8:: with SMTP id ds24mr11800440pjb.134.1607675472478; Fri, 11 Dec 2020 00:31:12 -0800 (PST) Received: from localhost.localdomain (59-125-13-244.HINET-IP.hinet.net. [59.125.13.244]) by smtp.gmail.com with ESMTPSA id l66sm8885410pgl.24.2020.12.11.00.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 00:31:11 -0800 (PST) From: Peilin Ye To: Mauro Carvalho Chehab Cc: Laurent Pinchart , Sean Young , Brad Love , Wolfram Sang , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Peilin Ye Subject: [PATCH] media: dvbdev: Fix memory leak in dvb_media_device_free() Date: Fri, 11 Dec 2020 03:30:39 -0500 Message-Id: <20201211083039.521617-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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." Cc: stable@vger.kernel.org Fixes: 0230d60e4661 ("[media] dvbdev: Add RF connector if needed") Reported-by: syzbot+7f09440acc069a0d38ac@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=9bbe4b842c98f0ed05c5eed77a226e9de33bf298 Signed-off-by: Peilin Ye --- drivers/media/dvb-core/dvbdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 959fa2820259..ec9ebff28552 100644 --- 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 dvb_device *dvbdev) 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; -- 2.25.1