Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1694775

[PATCH 2/4] gpio: tegra: Prefer kcalloc() over kzalloc() with multiplies

From Thierry Reding <thierry.reding@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 2/4] gpio: tegra: Prefer kcalloc() over kzalloc() with multiplies
Date 2017-07-24 17:00 +0200
Message-ID <u6MZX-6gF-1@gated-at.bofh.it> (permalink)
References <u6MZX-6gF-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Thierry Reding <treding@nvidia.com>

Rather than manually compute the size of an array, pass the number and
element size to kcalloc().

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpio/gpio-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 63ee221f9be9..1d4df290d7ab 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -621,10 +621,10 @@ static int tegra_gpio_probe(struct platform_device *pdev)
 	if (tgi->soc->debounce_supported)
 		tgi->gc.set_config = tegra_gpio_set_config;
 
-	tgi->bank_info = devm_kzalloc(&pdev->dev, tgi->bank_count *
+	tgi->bank_info = devm_kcalloc(&pdev->dev, tgi->bank_count,
 				      sizeof(*tgi->bank_info), GFP_KERNEL);
 	if (!tgi->bank_info)
-		return -ENODEV;
+		return -ENOMEM;
 
 	tgi->irq_domain = irq_domain_add_linear(pdev->dev.of_node,
 						tgi->gc.ngpio,
-- 
2.13.3

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 2/4] gpio: tegra: Prefer kcalloc() over kzalloc() with multiplies Thierry Reding <thierry.reding@gmail.com> - 2017-07-24 17:00 +0200
  Re: [PATCH 2/4] gpio: tegra: Prefer kcalloc() over kzalloc() with  multiplies Jon Hunter <jonathanh@nvidia.com> - 2017-07-25 10:30 +0200

csiph-web