2020-07-27 01:52:02

by Xu Wang

[permalink] [raw]
Subject: [PATCH] coresight: Use devm_kcalloc() in coresight_alloc_conns()

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".

Signed-off-by: Xu Wang <[email protected]>
---
drivers/hwtracing/coresight/coresight-platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index e4912abda3aa..d1460b6e4e07 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -27,7 +27,7 @@ static int coresight_alloc_conns(struct device *dev,
struct coresight_platform_data *pdata)
{
if (pdata->nr_outport) {
- pdata->conns = devm_kzalloc(dev, pdata->nr_outport *
+ pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
sizeof(*pdata->conns),
GFP_KERNEL);
if (!pdata->conns)
--
2.17.1


2020-07-28 21:39:19

by Mathieu Poirier

[permalink] [raw]
Subject: Re: [PATCH] coresight: Use devm_kcalloc() in coresight_alloc_conns()

On Sun, 26 Jul 2020 at 19:51, Xu Wang <[email protected]> wrote:
>
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "devm_kcalloc".
>
> Signed-off-by: Xu Wang <[email protected]>
> ---
> drivers/hwtracing/coresight/coresight-platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
> index e4912abda3aa..d1460b6e4e07 100644
> --- a/drivers/hwtracing/coresight/coresight-platform.c
> +++ b/drivers/hwtracing/coresight/coresight-platform.c
> @@ -27,7 +27,7 @@ static int coresight_alloc_conns(struct device *dev,
> struct coresight_platform_data *pdata)
> {
> if (pdata->nr_outport) {
> - pdata->conns = devm_kzalloc(dev, pdata->nr_outport *
> + pdata->conns = devm_kcalloc(dev, pdata->nr_outport,

https://lkml.org/lkml/2020/5/27/1098

> sizeof(*pdata->conns),
> GFP_KERNEL);
> if (!pdata->conns)
> --
> 2.17.1
>