All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] crypto/bcm: Adjustments for do_shash()
@ 2018-02-14 21:38 ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-14 21:38 UTC (permalink / raw)
  To: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Herbert Xu, Rob Rice, Steve Lin
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Feb 2018 22:30:07 +0100

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

Markus Elfring (2):
  Delete an error message for a failed memory allocation
  One function call less after error detection

 drivers/crypto/bcm/util.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

-- 
2.16.1

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

* [PATCH 0/2] crypto/bcm: Adjustments for do_shash()
@ 2018-02-14 21:38 ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-14 21:38 UTC (permalink / raw)
  To: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Herbert Xu, Rob Rice, Steve Lin
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Feb 2018 22:30:07 +0100

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

Markus Elfring (2):
  Delete an error message for a failed memory allocation
  One function call less after error detection

 drivers/crypto/bcm/util.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

-- 
2.16.1


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

* [PATCH 1/2] crypto: bcm: Delete an error message for a failed memory allocation in do_shash()
  2018-02-14 21:38 ` SF Markus Elfring
@ 2018-02-14 21:39   ` SF Markus Elfring
  -1 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-14 21:39 UTC (permalink / raw)
  To: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Herbert Xu, Rob Rice, Steve Lin
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Feb 2018 22:05:11 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/bcm/util.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c
index d543c010ccd9..a912c6ad3e85 100644
--- a/drivers/crypto/bcm/util.c
+++ b/drivers/crypto/bcm/util.c
@@ -279,7 +279,6 @@ int do_shash(unsigned char *name, unsigned char *result,
 	sdesc = kmalloc(size, GFP_KERNEL);
 	if (!sdesc) {
 		rc = -ENOMEM;
-		pr_err("%s: Memory allocation failure\n", __func__);
 		goto do_shash_err;
 	}
 	sdesc->shash.tfm = hash;
-- 
2.16.1

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

* [PATCH 1/2] crypto: bcm: Delete an error message for a failed memory allocation in do_shash()
@ 2018-02-14 21:39   ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-14 21:39 UTC (permalink / raw)
  To: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Herbert Xu, Rob Rice, Steve Lin
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Feb 2018 22:05:11 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/bcm/util.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c
index d543c010ccd9..a912c6ad3e85 100644
--- a/drivers/crypto/bcm/util.c
+++ b/drivers/crypto/bcm/util.c
@@ -279,7 +279,6 @@ int do_shash(unsigned char *name, unsigned char *result,
 	sdesc = kmalloc(size, GFP_KERNEL);
 	if (!sdesc) {
 		rc = -ENOMEM;
-		pr_err("%s: Memory allocation failure\n", __func__);
 		goto do_shash_err;
 	}
 	sdesc->shash.tfm = hash;
-- 
2.16.1


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

* [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection
  2018-02-14 21:38 ` SF Markus Elfring
@ 2018-02-14 21:40   ` SF Markus Elfring
  -1 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-14 21:40 UTC (permalink / raw)
  To: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Herbert Xu, Rob Rice, Steve Lin
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Feb 2018 22:22:20 +0100

The kfree() function was called in one case by the do_shash() function
during error handling even if the passed variable contained a null pointer.

* Reorder two function calls at the end.

* Add a jump target.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/bcm/util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c
index a912c6ad3e85..c141a0242223 100644
--- a/drivers/crypto/bcm/util.c
+++ b/drivers/crypto/bcm/util.c
@@ -279,7 +279,7 @@ int do_shash(unsigned char *name, unsigned char *result,
 	sdesc = kmalloc(size, GFP_KERNEL);
 	if (!sdesc) {
 		rc = -ENOMEM;
-		goto do_shash_err;
+		goto free_shash;
 	}
 	sdesc->shash.tfm = hash;
 	sdesc->shash.flags = 0x0;
@@ -314,9 +314,9 @@ int do_shash(unsigned char *name, unsigned char *result,
 		pr_err("%s: Could not generate %s hash\n", __func__, name);
 
 do_shash_err:
-	crypto_free_shash(hash);
 	kfree(sdesc);
-
+free_shash:
+	crypto_free_shash(hash);
 	return rc;
 }
 
-- 
2.16.1

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

* [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection
@ 2018-02-14 21:40   ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-14 21:40 UTC (permalink / raw)
  To: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Herbert Xu, Rob Rice, Steve Lin
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Feb 2018 22:22:20 +0100

The kfree() function was called in one case by the do_shash() function
during error handling even if the passed variable contained a null pointer.

* Reorder two function calls at the end.

* Add a jump target.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/bcm/util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c
index a912c6ad3e85..c141a0242223 100644
--- a/drivers/crypto/bcm/util.c
+++ b/drivers/crypto/bcm/util.c
@@ -279,7 +279,7 @@ int do_shash(unsigned char *name, unsigned char *result,
 	sdesc = kmalloc(size, GFP_KERNEL);
 	if (!sdesc) {
 		rc = -ENOMEM;
-		goto do_shash_err;
+		goto free_shash;
 	}
 	sdesc->shash.tfm = hash;
 	sdesc->shash.flags = 0x0;
@@ -314,9 +314,9 @@ int do_shash(unsigned char *name, unsigned char *result,
 		pr_err("%s: Could not generate %s hash\n", __func__, name);
 
 do_shash_err:
-	crypto_free_shash(hash);
 	kfree(sdesc);
-
+free_shash:
+	crypto_free_shash(hash);
 	return rc;
 }
 
-- 
2.16.1


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

* Re: [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection
  2018-02-14 21:40   ` SF Markus Elfring
@ 2018-02-22 13:42     ` Herbert Xu
  -1 siblings, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2018-02-22 13:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Rob Rice, Steve Lin, LKML, kernel-janitors

On Wed, Feb 14, 2018 at 10:40:26PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Feb 2018 22:22:20 +0100
> 
> The kfree() function was called in one case by the do_shash() function
> during error handling even if the passed variable contained a null pointer.
> 
> * Reorder two function calls at the end.
> 
> * Add a jump target.

This patch is pointless as kfree on NULL is a no-op.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection
@ 2018-02-22 13:42     ` Herbert Xu
  0 siblings, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2018-02-22 13:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Rob Rice, Steve Lin, LKML, kernel-janitors

On Wed, Feb 14, 2018 at 10:40:26PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Feb 2018 22:22:20 +0100
> 
> The kfree() function was called in one case by the do_shash() function
> during error handling even if the passed variable contained a null pointer.
> 
> * Reorder two function calls at the end.
> 
> * Add a jump target.

This patch is pointless as kfree on NULL is a no-op.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH 1/2] crypto: bcm: Delete an error message for a failed memory allocation in do_shash()
  2018-02-14 21:39   ` SF Markus Elfring
@ 2018-02-22 15:13     ` Herbert Xu
  -1 siblings, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2018-02-22 15:13 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Rob Rice, Steve Lin, LKML, kernel-janitors

On Wed, Feb 14, 2018 at 10:39:25PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Feb 2018 22:05:11 +0100
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH 1/2] crypto: bcm: Delete an error message for a failed memory allocation in do_shash()
@ 2018-02-22 15:13     ` Herbert Xu
  0 siblings, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2018-02-22 15:13 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-crypto, Arvind Yadav, Colin Ian King, David S. Miller,
	Rob Rice, Steve Lin, LKML, kernel-janitors

On Wed, Feb 14, 2018 at 10:39:25PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Feb 2018 22:05:11 +0100
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [2/2] crypto: bcm: One function call less in do_shash() after error detection
  2018-02-22 13:42     ` Herbert Xu
@ 2018-02-23  8:23       ` SF Markus Elfring
  -1 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-23  8:23 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto
  Cc: Arvind Yadav, Colin Ian King, David S. Miller, Rob Rice,
	Steve Lin, LKML, kernel-janitors

> This patch is pointless as kfree on NULL is a no-op.

I prefer to avoid unnecessary function calls generally.

Regards,
Markus

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

* Re: [2/2] crypto: bcm: One function call less in do_shash() after error detection
@ 2018-02-23  8:23       ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2018-02-23  8:23 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto
  Cc: Arvind Yadav, Colin Ian King, David S. Miller, Rob Rice,
	Steve Lin, LKML, kernel-janitors

> This patch is pointless as kfree on NULL is a no-op.

I prefer to avoid unnecessary function calls generally.

Regards,
Markus

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

end of thread, other threads:[~2018-02-23  8:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 21:38 [PATCH 0/2] crypto/bcm: Adjustments for do_shash() SF Markus Elfring
2018-02-14 21:38 ` SF Markus Elfring
2018-02-14 21:39 ` [PATCH 1/2] crypto: bcm: Delete an error message for a failed memory allocation in do_shash() SF Markus Elfring
2018-02-14 21:39   ` SF Markus Elfring
2018-02-22 15:13   ` Herbert Xu
2018-02-22 15:13     ` Herbert Xu
2018-02-14 21:40 ` [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection SF Markus Elfring
2018-02-14 21:40   ` SF Markus Elfring
2018-02-22 13:42   ` Herbert Xu
2018-02-22 13:42     ` Herbert Xu
2018-02-23  8:23     ` [2/2] " SF Markus Elfring
2018-02-23  8:23       ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.