linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sinan Kaya <okaya@codeaurora.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
	dmaengine@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-soc@vger.kernel.org, Andy Gross <andy.gross@linaro.org>,
	Dan Williams <dan.j.williams@intel.com>,
	David Brown <david.brown@linaro.org>,
	Vinod Koul <vinod.koul@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] hidma_mgmt_sys: Use devm_kmalloc_array() in hidma_mgmt_init_sys()
Date: Mon, 17 Apr 2017 18:23:33 -0400	[thread overview]
Message-ID: <21cb2036-2bdb-9024-a07b-a72dab747b44@codeaurora.org> (raw)
In-Reply-To: <89811982-af2d-3ab3-0ab3-ddb6e4ca369f@users.sourceforge.net>

On 4/17/2017 4:55 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 17 Apr 2017 22:42:40 +0200
> 
> * 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_kmalloc_array".
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Delete the local variable "required" which became unnecessary
>   with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/dma/qcom/hidma_mgmt_sys.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma/qcom/hidma_mgmt_sys.c b/drivers/dma/qcom/hidma_mgmt_sys.c
> index d61f1068a34b..e7222a0e9ba4 100644
> --- a/drivers/dma/qcom/hidma_mgmt_sys.c
> +++ b/drivers/dma/qcom/hidma_mgmt_sys.c
> @@ -245,11 +245,12 @@ int hidma_mgmt_init_sys(struct hidma_mgmt_dev *mdev)
>  {
>  	unsigned int i;
>  	int rc;
> -	int required;
>  	struct kobject *chanops;
>  
> -	required = sizeof(*mdev->chroots) * mdev->dma_channels;
> -	mdev->chroots = devm_kmalloc(&mdev->pdev->dev, required, GFP_KERNEL);
> +	mdev->chroots = devm_kmalloc_array(&mdev->pdev->dev,
> +					   mdev->dma_channels,
> +					   sizeof(*mdev->chroots),
> +					   GFP_KERNEL);
>  	if (!mdev->chroots)
>  		return -ENOMEM;
>  
> 

Reviewed-by: Sinan Kaya <okaya@codeauora.org>



-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.

      reply	other threads:[~2017-04-17 22:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-17 20:55 [PATCH] hidma_mgmt_sys: Use devm_kmalloc_array() in hidma_mgmt_init_sys() SF Markus Elfring
2017-04-17 22:23 ` Sinan Kaya [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21cb2036-2bdb-9024-a07b-a72dab747b44@codeaurora.org \
    --to=okaya@codeaurora.org \
    --cc=andy.gross@linaro.org \
    --cc=dan.j.williams@intel.com \
    --cc=david.brown@linaro.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).