Prechádzať zdrojové kódy

clk: mvebu: Use kcalloc() in two functions

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Markus Elfring 8 rokov pred
rodič
commit
ee7d74339d
1 zmenil súbory, kde vykonal 2 pridanie a 2 odobranie
  1. 2 2
      drivers/clk/mvebu/common.c

+ 2 - 2
drivers/clk/mvebu/common.c

@@ -126,7 +126,7 @@ void __init mvebu_coreclk_setup(struct device_node *np,
 	if (desc->get_refclk_freq)
 	if (desc->get_refclk_freq)
 		clk_data.clk_num += 1;
 		clk_data.clk_num += 1;
 
 
-	clk_data.clks = kzalloc(clk_data.clk_num * sizeof(struct clk *),
+	clk_data.clks = kcalloc(clk_data.clk_num, sizeof(*clk_data.clks),
 				GFP_KERNEL);
 				GFP_KERNEL);
 	if (WARN_ON(!clk_data.clks)) {
 	if (WARN_ON(!clk_data.clks)) {
 		iounmap(base);
 		iounmap(base);
@@ -270,7 +270,7 @@ void __init mvebu_clk_gating_setup(struct device_node *np,
 		n++;
 		n++;
 
 
 	ctrl->num_gates = n;
 	ctrl->num_gates = n;
-	ctrl->gates = kzalloc(ctrl->num_gates * sizeof(struct clk *),
+	ctrl->gates = kcalloc(ctrl->num_gates, sizeof(*ctrl->gates),
 			      GFP_KERNEL);
 			      GFP_KERNEL);
 	if (WARN_ON(!ctrl->gates))
 	if (WARN_ON(!ctrl->gates))
 		goto gates_out;
 		goto gates_out;