linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] PowerPC-Cell platform: Adjustments for four function implementations
@ 2017-10-05 19:34 SF Markus Elfring
  2017-10-05 19:36 ` [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
  2017-10-05 19:38 ` [PATCH 2/2] powerpc/platforms/cell: Improve a size determination " SF Markus Elfring
  0 siblings, 2 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-10-05 19:34 UTC (permalink / raw)
  To: linuxppc-dev, Arnd Bergmann, Benjamin Herrenschmidt, Jeremy Kerr,
	Michael Ellerman, Paul Mackerras
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Oct 2017 21:25:43 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an error message for a failed memory allocation in three functions
  Improve a size determination in three functions

 arch/powerpc/platforms/cell/axon_msi.c          |  7 ++-----
 arch/powerpc/platforms/cell/spider-pci.c        | 11 +++--------
 arch/powerpc/platforms/cell/spufs/lscsa_alloc.c |  2 +-
 3 files changed, 6 insertions(+), 14 deletions(-)

-- 
2.14.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions
  2017-10-05 19:34 [PATCH 0/2] PowerPC-Cell platform: Adjustments for four function implementations SF Markus Elfring
@ 2017-10-05 19:36 ` SF Markus Elfring
  2017-10-05 20:02   ` Michal Suchánek
  2017-10-05 19:38 ` [PATCH 2/2] powerpc/platforms/cell: Improve a size determination " SF Markus Elfring
  1 sibling, 1 reply; 7+ messages in thread
From: SF Markus Elfring @ 2017-10-05 19:36 UTC (permalink / raw)
  To: linuxppc-dev, Arnd Bergmann, Benjamin Herrenschmidt, Jeremy Kerr,
	Michael Ellerman, Paul Mackerras
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Oct 2017 21:04:30 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/cell/axon_msi.c   | 5 +----
 arch/powerpc/platforms/cell/spider-pci.c | 9 ++-------
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 6ea3f248b155..513d13d779b3 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -343,11 +343,8 @@ static int axon_msi_probe(struct platform_device *device)
 	pr_devel("axon_msi: setting up dn %pOF\n", dn);
 
 	msic = kzalloc(sizeof(struct axon_msic), GFP_KERNEL);
-	if (!msic) {
-		printk(KERN_ERR "axon_msi: couldn't allocate msic for %pOF\n",
-		       dn);
+	if (!msic)
 		goto out;
-	}
 
 	dcr_base = dcr_resource_start(dn, 0);
 	dcr_len = dcr_resource_len(dn, 0);
diff --git a/arch/powerpc/platforms/cell/spider-pci.c b/arch/powerpc/platforms/cell/spider-pci.c
index d1e61e273e64..0a9f00563144 100644
--- a/arch/powerpc/platforms/cell/spider-pci.c
+++ b/arch/powerpc/platforms/cell/spider-pci.c
@@ -104,10 +104,8 @@ static int __init spiderpci_pci_setup_chip(struct pci_controller *phb,
 	 * Celleb does not have this problem, because it has only one XDR.
 	 */
 	dummy_page_va = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	if (!dummy_page_va) {
-		pr_err("SPIDERPCI-IOWA:Alloc dummy_page_va failed.\n");
+	if (!dummy_page_va)
 		return -1;
-	}
 
 	dummy_page_da = dma_map_single(phb->parent, dummy_page_va,
 				       PAGE_SIZE, DMA_FROM_DEVICE);
@@ -134,11 +132,8 @@ int __init spiderpci_iowa_init(struct iowa_bus *bus, void *data)
 		 np);
 
 	priv = kzalloc(sizeof(struct spiderpci_iowa_private), GFP_KERNEL);
-	if (!priv) {
-		pr_err("SPIDERPCI-IOWA:"
-		       "Can't allocate struct spiderpci_iowa_private");
+	if (!priv)
 		return -1;
-	}
 
 	if (of_address_to_resource(np, 0, &r)) {
 		pr_err("SPIDERPCI-IOWA:Can't get resource.\n");
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] powerpc/platforms/cell: Improve a size determination in three functions
  2017-10-05 19:34 [PATCH 0/2] PowerPC-Cell platform: Adjustments for four function implementations SF Markus Elfring
  2017-10-05 19:36 ` [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
@ 2017-10-05 19:38 ` SF Markus Elfring
  1 sibling, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-10-05 19:38 UTC (permalink / raw)
  To: linuxppc-dev, Arnd Bergmann, Benjamin Herrenschmidt, Jeremy Kerr,
	Michael Ellerman, Paul Mackerras
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Oct 2017 21:12:41 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/cell/axon_msi.c          | 2 +-
 arch/powerpc/platforms/cell/spider-pci.c        | 2 +-
 arch/powerpc/platforms/cell/spufs/lscsa_alloc.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 513d13d779b3..cc4987664841 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -342,7 +342,7 @@ static int axon_msi_probe(struct platform_device *device)
 
 	pr_devel("axon_msi: setting up dn %pOF\n", dn);
 
-	msic = kzalloc(sizeof(struct axon_msic), GFP_KERNEL);
+	msic = kzalloc(sizeof(*msic), GFP_KERNEL);
 	if (!msic)
 		goto out;
 
diff --git a/arch/powerpc/platforms/cell/spider-pci.c b/arch/powerpc/platforms/cell/spider-pci.c
index 0a9f00563144..31919ff00124 100644
--- a/arch/powerpc/platforms/cell/spider-pci.c
+++ b/arch/powerpc/platforms/cell/spider-pci.c
@@ -131,7 +131,7 @@ int __init spiderpci_iowa_init(struct iowa_bus *bus, void *data)
 	pr_debug("SPIDERPCI-IOWA:Bus initialize for spider(%pOF)\n",
 		 np);
 
-	priv = kzalloc(sizeof(struct spiderpci_iowa_private), GFP_KERNEL);
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -1;
 
diff --git a/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c b/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
index b847e9403566..d9de848dae47 100644
--- a/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
+++ b/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
@@ -36,7 +36,7 @@ int spu_alloc_lscsa(struct spu_state *csa)
 	struct spu_lscsa *lscsa;
 	unsigned char *p;
 
-	lscsa = vzalloc(sizeof(struct spu_lscsa));
+	lscsa = vzalloc(sizeof(*lscsa));
 	if (!lscsa)
 		return -ENOMEM;
 	csa->lscsa = lscsa;
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions
  2017-10-05 19:36 ` [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
@ 2017-10-05 20:02   ` Michal Suchánek
  2017-10-05 20:06     ` Julia Lawall
  0 siblings, 1 reply; 7+ messages in thread
From: Michal Suchánek @ 2017-10-05 20:02 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linuxppc-dev, Arnd Bergmann, Benjamin Herrenschmidt, Jeremy Kerr,
	Michael Ellerman, Paul Mackerras, kernel-janitors, LKML

Hello,

On Thu, 5 Oct 2017 21:36:26 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Oct 2017 21:04:30 +0200
> 
> Omit extra messages for a memory allocation failure in these
> functions.

this is bogus. All these functions return -1 on any error. Until they
reflect the error in their return value (and it is properly propagated
to the user) there is no way to tell WTF failed without the message.

> 
> This issue was detected by using the Coccinelle software.
> 

... which provides only a hint which should be evaluated by the user.

Thanks

Michal

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions
  2017-10-05 20:02   ` Michal Suchánek
@ 2017-10-05 20:06     ` Julia Lawall
  2017-10-05 20:29       ` Michal Suchánek
  0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2017-10-05 20:06 UTC (permalink / raw)
  To: Michal Suchánek
  Cc: SF Markus Elfring, linuxppc-dev, Arnd Bergmann,
	Benjamin Herrenschmidt, Jeremy Kerr, Michael Ellerman,
	Paul Mackerras, kernel-janitors, LKML

[-- Attachment #1: Type: text/plain, Size: 970 bytes --]



On Thu, 5 Oct 2017, Michal Suchánek wrote:

> Hello,
>
> On Thu, 5 Oct 2017 21:36:26 +0200
> SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Thu, 5 Oct 2017 21:04:30 +0200
> >
> > Omit extra messages for a memory allocation failure in these
> > functions.
>
> this is bogus. All these functions return -1 on any error. Until they
> reflect the error in their return value (and it is properly propagated
> to the user) there is no way to tell WTF failed without the message.

A backtrace will be generated.

julia

>
> >
> > This issue was detected by using the Coccinelle software.
> >
>
> ... which provides only a hint which should be evaluated by the user.
>
> Thanks
>
> Michal
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions
  2017-10-05 20:06     ` Julia Lawall
@ 2017-10-05 20:29       ` Michal Suchánek
  2017-10-06  2:02         ` Joe Perches
  0 siblings, 1 reply; 7+ messages in thread
From: Michal Suchánek @ 2017-10-05 20:29 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Arnd Bergmann, kernel-janitors, LKML, Paul Mackerras,
	Jeremy Kerr, linuxppc-dev, SF Markus Elfring

On Thu, 5 Oct 2017 22:06:11 +0200 (CEST)
Julia Lawall <julia.lawall@lip6.fr> wrote:

> On Thu, 5 Oct 2017, Michal Such=C3=A1nek wrote:
>=20
> > Hello,
> >
> > On Thu, 5 Oct 2017 21:36:26 +0200
> > SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> > =20
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Thu, 5 Oct 2017 21:04:30 +0200
> > >
> > > Omit extra messages for a memory allocation failure in these
> > > functions. =20
> >
> > this is bogus. All these functions return -1 on any error. Until
> > they reflect the error in their return value (and it is properly
> > propagated to the user) there is no way to tell WTF failed without
> > the message. =20
>=20
> A backtrace will be generated.
>=20

I do not see why it would. I do not expect the kernel to generate a
stack trace every time memory allocation fails. With all the hooks in
the code it is hard to tell, though.

Thanks

Michal

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions
  2017-10-05 20:29       ` Michal Suchánek
@ 2017-10-06  2:02         ` Joe Perches
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2017-10-06  2:02 UTC (permalink / raw)
  To: Michal Suchánek, Julia Lawall
  Cc: Arnd Bergmann, kernel-janitors, LKML, Paul Mackerras,
	Jeremy Kerr, linuxppc-dev, SF Markus Elfring

On Thu, 2017-10-05 at 22:29 +0200, Michal Suchánek wrote:
> I do not expect the kernel to generate a
> stack trace every time memory allocation fails. With all the hooks in
> the code it is hard to tell, though.

All [kv].alloc failures without __GFP_NOWARN call dump_stack()

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-06  2:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 19:34 [PATCH 0/2] PowerPC-Cell platform: Adjustments for four function implementations SF Markus Elfring
2017-10-05 19:36 ` [PATCH 1/2] powerpc/platforms/cell: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-10-05 20:02   ` Michal Suchánek
2017-10-05 20:06     ` Julia Lawall
2017-10-05 20:29       ` Michal Suchánek
2017-10-06  2:02         ` Joe Perches
2017-10-05 19:38 ` [PATCH 2/2] powerpc/platforms/cell: Improve a size determination " SF Markus Elfring

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).