aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorHimangi Saraogi <himangi774@gmail.com>2014-07-19 17:53:35 -0400
committerScott Wood <scottwood@freescale.com>2014-07-29 20:26:31 -0400
commit983e2444100667b4b35c9d56c9a1fec1e817143c (patch)
tree8dbd5f0244c65cda464e0eef3ffc9477f1cb1aef /arch
parent54afbec0d57f322127e3886b04fe4fd860519bfb (diff)
powerpc/mpic_msgr: Use kcalloc and correct the argument to sizeof
mpic_msgrs has type struct mpic_msgr **, not struct mpic_msgr *, so the elements of the array should have pointer type, not structure type. The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. The Coccinelle semantic patch that makes the first change is as follows: // <smpl> @disable sizeof_type_expr@ type T; T **x; @@ x = <+...sizeof( - T + *x )...+> // </smpl> Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/sysdev/mpic_msgr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/sysdev/mpic_msgr.c b/arch/powerpc/sysdev/mpic_msgr.c
index 2c9b52aa266c..7bdf3cc741e4 100644
--- a/arch/powerpc/sysdev/mpic_msgr.c
+++ b/arch/powerpc/sysdev/mpic_msgr.c
@@ -184,7 +184,7 @@ static int mpic_msgr_probe(struct platform_device *dev)
184 dev_info(&dev->dev, "Found %d message registers\n", 184 dev_info(&dev->dev, "Found %d message registers\n",
185 mpic_msgr_count); 185 mpic_msgr_count);
186 186
187 mpic_msgrs = kzalloc(sizeof(struct mpic_msgr) * mpic_msgr_count, 187 mpic_msgrs = kcalloc(mpic_msgr_count, sizeof(*mpic_msgrs),
188 GFP_KERNEL); 188 GFP_KERNEL);
189 if (!mpic_msgrs) { 189 if (!mpic_msgrs) {
190 dev_err(&dev->dev, 190 dev_err(&dev->dev,