Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3695796imu; Mon, 28 Jan 2019 09:11:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN5/sJ4AiX6PCJ22inVHLGpnWonlpfqIFtgyAC/IHFbBzQLfsG1fsYnfz9d+yVlUWWjd1izi X-Received: by 2002:a17:902:59c8:: with SMTP id d8mr22594133plj.116.1548695507624; Mon, 28 Jan 2019 09:11:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695507; cv=none; d=google.com; s=arc-20160816; b=fPDRJyYQIhBFjmIFnpvXbakPIRiaEy2rCgy0BX1i/dtoJlPHcQT+OgWHT/pHaQ6/dt QeMDKs7wuPxFdqmwWcEC29jXffHQug6AEKauOTxEVjm1tjIV+3nbj8YvRneFfHdDDVXv YHsVn2mofIRiaOBYjljgFsrXcs9XFQu5pxrD9UAyvjXU6adEZkMZ8vMTDTDK86DsNxAs PfS6wwgQRZCUk+ususCekbImIDclaTYtaBAWKARY5M+i578gAq0nN6Ggl8ksCC92s3oz w2fkJp0oV/CCTz/sRwXMCWMQbhk6Jwkee/08ldoXLVpk1ewkWpnbIQ+VR/6zNdmG7978 J9wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=81w/J8RzPSknsOUG5vQfPvWq1SZSKRH4Rg1uQxcALSU=; b=N+CmEHjuqfIP3ury1YWKA+BFRsVYXQzooQu9i25xjdL9a4oZR4TVgbqmTDOlUq6qE/ tov2MDmqFZsSQFfwWxCBa6+6G4uGdni65EAdj1hbtmuid84QKR5mmXDq5SKeS94WxFdh GEh16E7SGsDebcrgxX4hOHtj46VtljNTiuiD3JfbWLwyo/wXEvxe9AyBOIto1kQOjksn 3N7WPX73dpyRx9y7RIIdjYO3hBfg8QZGeScqF3gK1PoAtlcK8PEGXWDiJpTN8xnOpb5v ONTLXzMeiq++zcJA3s0w7uz2uq+4wyNpXeEbu905emYHJnqLw/EfzDrZpg9600aN9GUe FB3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=opCct87O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf16si34022439plb.227.2019.01.28.09.11.32; Mon, 28 Jan 2019 09:11:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=opCct87O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387441AbfA1RKE (ORCPT + 99 others); Mon, 28 Jan 2019 12:10:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:37850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732020AbfA1QLH (ORCPT ); Mon, 28 Jan 2019 11:11:07 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 898EC2147A; Mon, 28 Jan 2019 16:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691866; bh=Cjnvp5qGsnXsNBP0R+FoSvIo9939kgzQkp72htoFvEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=opCct87OSPLeTly5cMJA0Q5yMamttCnAaIrv4nnI3UctVWEwC9jEhbm0bQnZZsl52 2V5Uq5AWc3UGAU2e1WgaRB8Uxvd2PAdkd5Ski32Y1QeD98RNctszXHCa4sAiyxSvi9 8qyg3M0PdG7JGnNupTJB7tlZnPKS2w7GmYdYGJF4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wenwen Wang , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.19 241/258] gdrom: fix a memory leak bug Date: Mon, 28 Jan 2019 10:59:07 -0500 Message-Id: <20190128155924.51521-241-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang [ Upstream commit 093c48213ee37c3c3ff1cf5ac1aa2a9d8bc66017 ] In probe_gdrom(), the buffer pointed by 'gd.cd_info' is allocated through kzalloc() and is used to hold the information of the gdrom device. To register and unregister the device, the pointer 'gd.cd_info' is passed to the functions register_cdrom() and unregister_cdrom(), respectively. However, this buffer is not freed after it is used, which can cause a memory leak bug. This patch simply frees the buffer 'gd.cd_info' in exit_gdrom() to fix the above issue. Signed-off-by: Wenwen Wang Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/cdrom/gdrom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index ae3a7537cf0f..72cd96a8eb19 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -889,6 +889,7 @@ static void __exit exit_gdrom(void) platform_device_unregister(pd); platform_driver_unregister(&gdrom_driver); kfree(gd.toc); + kfree(gd.cd_info); } module_init(init_gdrom); -- 2.19.1