linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Anju T Sudhakar <anju@linux.vnet.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Madhavan Srinivasan <maddy@linux.vnet.ibm.com>,
	Hemant Kumar <hemant@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, kernel-janitors@vger.kernel.org
Subject: powerpc/perf: Fix a sizeof() typo so we allocate less memory
Date: Sat, 4 Nov 2017 10:51:36 +0300	[thread overview]
Message-ID: <20171104075136.nujqcprikcevsfwv@mwanda> (raw)

We're allocating the size of the struct which is 32 bytes when we should
be allocating sizeof(void *) which is 4 or 8 bytes depending on the
architecture.

Fixes: 885dcd709ba9 ("powerpc/perf: Add nest IMC PMU support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index 88126245881b..91c90ddab807 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -210,7 +210,7 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu)
 	of_property_read_u32(node, "reg", &base_reg);
 
 	/* Allocate memory for the events */
-	pmu->events = kcalloc(ct, sizeof(struct imc_events), GFP_KERNEL);
+	pmu->events = kcalloc(ct, sizeof(*pmu->events), GFP_KERNEL);
 	if (!pmu->events)
 		return -ENOMEM;
 

             reply	other threads:[~2017-11-04  7:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-04  7:51 Dan Carpenter [this message]
2017-11-06 10:39 ` powerpc/perf: Fix a sizeof() typo so we allocate less memory Michael Ellerman

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=20171104075136.nujqcprikcevsfwv@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=anju@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=hemant@linux.vnet.ibm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.vnet.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /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).