From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from exprod5og111.obsmtp.com (exprod5og111.obsmtp.com [64.18.0.22]) by ozlabs.org (Postfix) with SMTP id 59BB62C017F for ; Mon, 9 Dec 2013 19:44:44 +1100 (EST) Received: by mail-bk0-f47.google.com with SMTP id mx12so1239501bkb.34 for ; Mon, 09 Dec 2013 00:44:41 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1386377017-909-1-git-send-email-imirkin@alum.mit.edu> References: <1386377017-909-1-git-send-email-imirkin@alum.mit.edu> Date: Mon, 9 Dec 2013 15:38:23 +0700 Message-ID: Subject: Re: [PATCH] powerpc/44x: fix ocm_block allocation From: Vinh Huu Tuong Nguyen To: Ilia Mirkin Content-Type: multipart/alternative; boundary=bcaec52c68ff35a2f704ed15ebc8 Cc: linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --bcaec52c68ff35a2f704ed15ebc8 Content-Type: text/plain; charset=ISO-8859-1 Hi Ilia Mirkin, Thanks for your info. I did investigated why our test didn't detect it and found out that the struct ocm_block is only used on ocm_debugfs_show function when we want to know information about ocm and it's available when we enable debugfs. But our test only tried to use the OCM block functions and didn't care about the OCM information. So I think we should apply your patch to solve this issue instead of removing ocm part. On Sat, Dec 7, 2013 at 7:43 AM, Ilia Mirkin wrote: > Allocate enough memory for the ocm_block structure, not just a pointer > to it. > > Signed-off-by: Ilia Mirkin > --- > > I have neither the hardware to test nor the toolchain to even build-test > this. However this seems like a fairly obvious fix (and I have to wonder > how > this ever worked at all). Found with spatch. > > Actually further investigation makes it seem like this function is never > called, perhaps it should just be removed? If it is kept around though, > would > be nice to apply this patch so that tools don't trip over this wrong code. > > arch/powerpc/sysdev/ppc4xx_ocm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/sysdev/ppc4xx_ocm.c > b/arch/powerpc/sysdev/ppc4xx_ocm.c > index b7c4345..85d9e37 100644 > --- a/arch/powerpc/sysdev/ppc4xx_ocm.c > +++ b/arch/powerpc/sysdev/ppc4xx_ocm.c > @@ -339,7 +339,7 @@ void *ppc4xx_ocm_alloc(phys_addr_t *phys, int size, > int align, > if (IS_ERR_VALUE(offset)) > continue; > > - ocm_blk = kzalloc(sizeof(struct ocm_block *), GFP_KERNEL); > + ocm_blk = kzalloc(sizeof(struct ocm_block), GFP_KERNEL); > if (!ocm_blk) { > printk(KERN_ERR "PPC4XX OCM: could not allocate > ocm block"); > rh_free(ocm_reg->rh, offset); > -- > 1.8.3.2 > > -- *Vinh Nguyen Huu Tuong **|** Staff SW Engineer* C: 090.335.7841 | O: 083.770.0640 ext: 3719 F: 083.770.0641 | vhtnguyen@apm.com --bcaec52c68ff35a2f704ed15ebc8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi=A0Ilia Mirkin,
Thanks for = your info. I did investigated why our test didn't detect it and found o= ut that the struct ocm_block is only used on=A0ocm_debugfs_show function wh= en we want to know information about ocm and it's available when we ena= ble debugfs. But our test only tried to use the OCM block functions and did= n't care about the OCM information. So I think we should apply your pat= ch to solve this issue instead of removing ocm part.



On Sat, Dec 7, 2013 at 7:43 AM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
Allocate enough memory for the ocm_block str= ucture, not just a pointer
to it.

Signed-off-by: Ilia Mirkin <imir= kin@alum.mit.edu>
---

I have neither the hardware to test nor the toolchain to even build-test this. However this seems like a fairly obvious fix (and I have to wonder ho= w
this ever worked at all). Found with spatch.

Actually further investigation makes it seem like this function is never called, perhaps it should just be removed? If it is kept around though, wou= ld
be nice to apply this patch so that tools don't trip over this wrong co= de.

=A0arch/powerpc/sysdev/ppc4xx_ocm.c | 2 +-
=A01 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/ppc4xx_ocm.c b/arch/powerpc/sysdev/ppc4xx_= ocm.c
index b7c4345..85d9e37 100644
--- a/arch/powerpc/sysdev/ppc4xx_ocm.c
+++ b/arch/powerpc/sysdev/ppc4xx_ocm.c
@@ -339,7 +339,7 @@ void *ppc4xx_ocm_alloc(phys_addr_t *phys, int size, int= align,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (IS_ERR_VALUE(offset))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue;

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 ocm_blk =3D kzalloc(sizeof(struct ocm_block *= ), GFP_KERNEL);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 ocm_blk =3D kzalloc(sizeof(struct ocm_block),= GFP_KERNEL);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!ocm_blk) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "PPC4X= X OCM: could not allocate ocm block");
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rh_free(ocm_reg->rh, off= set);
--
1.8.3.2




--

Vinh Nguyen Huu Tuong=A0|=A0Staff SW Engineer

C: 090.335.7841=A0|=A0O: 083= .770.0640 ext: 3719

F: 083.770.0641 |=A0vhtnguyen@apm.com








--bcaec52c68ff35a2f704ed15ebc8--