From ffa4280183e79062b433ec2f54fe4dd9f08def48 Mon Sep 17 00:00:00 2001 From: David Collins Date: Tue, 2 Mar 2021 15:47:32 -0800 Subject: [PATCH] regmap: qti-regmap-debugfs: use kzalloc() for read buffer allocation Change the kmalloc() call in regmap_read_debugfs() to kzalloc() to avoid a corner case in which copy_to_user() could be called with the contents of the 'buf' array unallocated. Change-Id: I9899ff01e8482f68d72247466ecf8615b1d0d35f Signed-off-by: David Collins --- drivers/base/regmap/qti-regmap-debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/regmap/qti-regmap-debugfs.c b/drivers/base/regmap/qti-regmap-debugfs.c index 515ac7859678..f4efff62ab91 100644 --- a/drivers/base/regmap/qti-regmap-debugfs.c +++ b/drivers/base/regmap/qti-regmap-debugfs.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2011 Wolfson Microelectronics plc - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. */ #include @@ -289,7 +289,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, if (count > (PAGE_SIZE << (MAX_ORDER - 1))) count = PAGE_SIZE << (MAX_ORDER - 1); - buf = kmalloc(count, GFP_KERNEL); + buf = kzalloc(count, GFP_KERNEL); if (!buf) return -ENOMEM;