* [PATCH 0/5] net-SCTP: Adjustments for three function implementations
@ 2017-05-22 16:35 SF Markus Elfring
2017-05-22 16:37 ` [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() SF Markus Elfring
` (5 more replies)
0 siblings, 6 replies; 20+ messages in thread
From: SF Markus Elfring @ 2017-05-22 16:35 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 18:30:45 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Use kmalloc_array() in sctp_init()
Delete an error message for a failed memory allocation in sctp_init()
Fix a typo in a comment line in sctp_init()
Improve a size determination in sctp_inetaddr_event()
Adjust one function call together with a variable assignment
net/sctp/protocol.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--
2.13.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init()
2017-05-22 16:35 [PATCH 0/5] net-SCTP: Adjustments for three function implementations SF Markus Elfring
@ 2017-05-22 16:37 ` SF Markus Elfring
2017-05-22 19:51 ` Marcelo Ricardo Leitner
2017-05-22 20:57 ` Vlad Yasevich
2017-05-22 16:38 ` [PATCH 2/5] sctp: Delete an error message for a failed memory allocation " SF Markus Elfring
` (4 subsequent siblings)
5 siblings, 2 replies; 20+ messages in thread
From: SF Markus Elfring @ 2017-05-22 16:37 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 17:20:11 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/protocol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 989a900383b5..2b1a6215bd2f 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1442,6 +1442,6 @@ static __init int sctp_init(void)
/* Allocate and initialize the endpoint hash table. */
sctp_ep_hashsize = 64;
- sctp_ep_hashtable =
- kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL);
+ sctp_ep_hashtable = kmalloc_array(64, sizeof(*sctp_ep_hashtable),
+ GFP_KERNEL);
if (!sctp_ep_hashtable) {
--
2.13.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/5] sctp: Delete an error message for a failed memory allocation in sctp_init()
2017-05-22 16:35 [PATCH 0/5] net-SCTP: Adjustments for three function implementations SF Markus Elfring
2017-05-22 16:37 ` [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() SF Markus Elfring
@ 2017-05-22 16:38 ` SF Markus Elfring
2017-05-22 16:56 ` Marcelo Ricardo Leitner
` (2 more replies)
2017-05-22 16:39 ` [PATCH 3/5] sctp: Fix a typo in a comment line " SF Markus Elfring
` (3 subsequent siblings)
5 siblings, 3 replies; 20+ messages in thread
From: SF Markus Elfring @ 2017-05-22 16:38 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 17:28:14 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/protocol.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2b1a6215bd2f..5e7c8a344770 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1447,5 +1447,4 @@ static __init int sctp_init(void)
if (!sctp_ep_hashtable) {
- pr_err("Failed endpoint_hash alloc\n");
status = -ENOMEM;
goto err_ehash_alloc;
}
--
2.13.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/5] sctp: Fix a typo in a comment line in sctp_init()
2017-05-22 16:35 [PATCH 0/5] net-SCTP: Adjustments for three function implementations SF Markus Elfring
2017-05-22 16:37 ` [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() SF Markus Elfring
2017-05-22 16:38 ` [PATCH 2/5] sctp: Delete an error message for a failed memory allocation " SF Markus Elfring
@ 2017-05-22 16:39 ` SF Markus Elfring
2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
2017-05-22 16:40 ` [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event() SF Markus Elfring
` (2 subsequent siblings)
5 siblings, 2 replies; 20+ messages in thread
From: SF Markus Elfring @ 2017-05-22 16:39 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 17:43:44 +0200
Add a missing character in this description.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/protocol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 5e7c8a344770..64756c42cec9 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1454,7 +1454,7 @@ static __init int sctp_init(void)
}
/* Allocate and initialize the SCTP port hash table.
- * Note that order is initalized to start at the max sized
+ * Note that order is initialized to start at the max sized
* table we want to support. If we can't get that many pages
* reduce the order and try again
*/
--
2.13.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event()
2017-05-22 16:35 [PATCH 0/5] net-SCTP: Adjustments for three function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-05-22 16:39 ` [PATCH 3/5] sctp: Fix a typo in a comment line " SF Markus Elfring
@ 2017-05-22 16:40 ` SF Markus Elfring
2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
2017-05-22 16:41 ` [PATCH 5/5] sctp: Adjust one function call together with a variable assignment SF Markus Elfring
2017-05-23 6:34 ` [PATCH 0/5] net-SCTP: Adjustments for three function implementations Xin Long
5 siblings, 2 replies; 20+ messages in thread
From: SF Markus Elfring @ 2017-05-22 16:40 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 18:08:24 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/protocol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 64756c42cec9..057479b7bd72 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -784,7 +784,7 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
switch (ev) {
case NETDEV_UP:
- addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
+ addr = kmalloc(sizeof(*addr), GFP_ATOMIC);
if (addr) {
addr->a.v4.sin_family = AF_INET;
addr->a.v4.sin_port = 0;
--
2.13.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/5] sctp: Adjust one function call together with a variable assignment
2017-05-22 16:35 [PATCH 0/5] net-SCTP: Adjustments for three function implementations SF Markus Elfring
` (3 preceding siblings ...)
2017-05-22 16:40 ` [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event() SF Markus Elfring
@ 2017-05-22 16:41 ` SF Markus Elfring
2017-05-22 19:53 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
2017-05-23 6:34 ` [PATCH 0/5] net-SCTP: Adjustments for three function implementations Xin Long
5 siblings, 2 replies; 20+ messages in thread
From: SF Markus Elfring @ 2017-05-22 16:41 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 18:15:12 +0200
The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus fix the affected source code place.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/protocol.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 057479b7bd72..be2fe3ebae78 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -141,7 +141,8 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
struct sctp_sockaddr_entry *addr;
rcu_read_lock();
- if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
+ in_dev = __in_dev_get_rcu(dev);
+ if (!in_dev) {
rcu_read_unlock();
return;
}
--
2.13.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] sctp: Delete an error message for a failed memory allocation in sctp_init()
2017-05-22 16:38 ` [PATCH 2/5] sctp: Delete an error message for a failed memory allocation " SF Markus Elfring
@ 2017-05-22 16:56 ` Marcelo Ricardo Leitner
2017-05-22 19:46 ` SF Markus Elfring
2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 20:59 ` Vlad Yasevich
2 siblings, 1 reply; 20+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-05-22 16:56 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich,
LKML, kernel-janitors
On Mon, May 22, 2017 at 06:38:21PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 17:28:14 +0200
>
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> net/sctp/protocol.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 2b1a6215bd2f..5e7c8a344770 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1447,5 +1447,4 @@ static __init int sctp_init(void)
> if (!sctp_ep_hashtable) {
> - pr_err("Failed endpoint_hash alloc\n");
Okay but then why not also delete the one a few lines below this one:
if (!sctp_port_hashtable) {
pr_err("Failed bind hash alloc\n");
status = -ENOMEM;
goto err_bhash_alloc;
}
Seems the same pattern to me.
> status = -ENOMEM;
> goto err_ehash_alloc;
> }
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" 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] 20+ messages in thread
* Re: [PATCH 2/5] sctp: Delete an error message for a failed memory allocation in sctp_init()
2017-05-22 16:56 ` Marcelo Ricardo Leitner
@ 2017-05-22 19:46 ` SF Markus Elfring
2017-05-22 19:50 ` Marcelo Ricardo Leitner
0 siblings, 1 reply; 20+ messages in thread
From: SF Markus Elfring @ 2017-05-22 19:46 UTC (permalink / raw)
To: Marcelo Ricardo Leitner, linux-sctp, netdev
Cc: David S. Miller, Neil Horman, Vlad Yasevich, LKML, kernel-janitors
>> +++ b/net/sctp/protocol.c
>> @@ -1447,5 +1447,4 @@ static __init int sctp_init(void)
>> if (!sctp_ep_hashtable) {
>> - pr_err("Failed endpoint_hash alloc\n");
>
> Okay but then why not also delete the one a few lines below this one:
> if (!sctp_port_hashtable) {
> pr_err("Failed bind hash alloc\n");
> status = -ENOMEM;
> goto err_bhash_alloc;
> }
> Seems the same pattern to me.
>
>> status = -ENOMEM;
>> goto err_ehash_alloc;
>> }
How do you think about to remove the other error message in another
update step if a consensus would be achieved in such a direction
for this software module?
Regards,
Markus
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] sctp: Delete an error message for a failed memory allocation in sctp_init()
2017-05-22 19:46 ` SF Markus Elfring
@ 2017-05-22 19:50 ` Marcelo Ricardo Leitner
0 siblings, 0 replies; 20+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-05-22 19:50 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich,
LKML, kernel-janitors
On Mon, May 22, 2017 at 09:46:21PM +0200, SF Markus Elfring wrote:
> >> +++ b/net/sctp/protocol.c
> >> @@ -1447,5 +1447,4 @@ static __init int sctp_init(void)
> >> if (!sctp_ep_hashtable) {
> >> - pr_err("Failed endpoint_hash alloc\n");
> >
> > Okay but then why not also delete the one a few lines below this one:
> > if (!sctp_port_hashtable) {
> > pr_err("Failed bind hash alloc\n");
> > status = -ENOMEM;
> > goto err_bhash_alloc;
> > }
> > Seems the same pattern to me.
> >
> >> status = -ENOMEM;
> >> goto err_ehash_alloc;
> >> }
>
> How do you think about to remove the other error message in another
> update step if a consensus would be achieved in such a direction
> for this software module?
Fine by me.
Regards,
Marcelo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init()
2017-05-22 16:37 ` [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() SF Markus Elfring
@ 2017-05-22 19:51 ` Marcelo Ricardo Leitner
2017-05-22 20:57 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-05-22 19:51 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich,
LKML, kernel-janitors
On Mon, May 22, 2017 at 06:37:19PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 17:20:11 +0200
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> * Replace the specification of a data structure by a pointer dereference
> to make the corresponding size determination a bit safer according to
> the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> net/sctp/protocol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 989a900383b5..2b1a6215bd2f 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1442,6 +1442,6 @@ static __init int sctp_init(void)
>
> /* Allocate and initialize the endpoint hash table. */
> sctp_ep_hashsize = 64;
> - sctp_ep_hashtable =
> - kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL);
> + sctp_ep_hashtable = kmalloc_array(64, sizeof(*sctp_ep_hashtable),
> + GFP_KERNEL);
> if (!sctp_ep_hashtable) {
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" 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] 20+ messages in thread
* Re: [PATCH 2/5] sctp: Delete an error message for a failed memory allocation in sctp_init()
2017-05-22 16:38 ` [PATCH 2/5] sctp: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-05-22 16:56 ` Marcelo Ricardo Leitner
@ 2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 20:59 ` Vlad Yasevich
2 siblings, 0 replies; 20+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-05-22 19:52 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich,
LKML, kernel-janitors
On Mon, May 22, 2017 at 06:38:21PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 17:28:14 +0200
>
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> net/sctp/protocol.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 2b1a6215bd2f..5e7c8a344770 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1447,5 +1447,4 @@ static __init int sctp_init(void)
> if (!sctp_ep_hashtable) {
> - pr_err("Failed endpoint_hash alloc\n");
> status = -ENOMEM;
> goto err_ehash_alloc;
> }
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" 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] 20+ messages in thread
* Re: [PATCH 3/5] sctp: Fix a typo in a comment line in sctp_init()
2017-05-22 16:39 ` [PATCH 3/5] sctp: Fix a typo in a comment line " SF Markus Elfring
@ 2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-05-22 19:52 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich,
LKML, kernel-janitors
On Mon, May 22, 2017 at 06:39:29PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 17:43:44 +0200
>
> Add a missing character in this description.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> net/sctp/protocol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 5e7c8a344770..64756c42cec9 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1454,7 +1454,7 @@ static __init int sctp_init(void)
> }
>
> /* Allocate and initialize the SCTP port hash table.
> - * Note that order is initalized to start at the max sized
> + * Note that order is initialized to start at the max sized
> * table we want to support. If we can't get that many pages
> * reduce the order and try again
> */
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" 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] 20+ messages in thread
* Re: [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event()
2017-05-22 16:40 ` [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event() SF Markus Elfring
@ 2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-05-22 19:52 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich,
LKML, kernel-janitors
On Mon, May 22, 2017 at 06:40:37PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 18:08:24 +0200
>
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> net/sctp/protocol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 64756c42cec9..057479b7bd72 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -784,7 +784,7 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
>
> switch (ev) {
> case NETDEV_UP:
> - addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
> + addr = kmalloc(sizeof(*addr), GFP_ATOMIC);
> if (addr) {
> addr->a.v4.sin_family = AF_INET;
> addr->a.v4.sin_port = 0;
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" 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] 20+ messages in thread
* Re: [PATCH 5/5] sctp: Adjust one function call together with a variable assignment
2017-05-22 16:41 ` [PATCH 5/5] sctp: Adjust one function call together with a variable assignment SF Markus Elfring
@ 2017-05-22 19:53 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-05-22 19:53 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich,
LKML, kernel-janitors
On Mon, May 22, 2017 at 06:41:45PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 18:15:12 +0200
>
> The script "checkpatch.pl" pointed information out like the following.
>
> ERROR: do not use assignment in if condition
>
> Thus fix the affected source code place.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> net/sctp/protocol.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 057479b7bd72..be2fe3ebae78 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -141,7 +141,8 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
> struct sctp_sockaddr_entry *addr;
>
> rcu_read_lock();
> - if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
> + in_dev = __in_dev_get_rcu(dev);
> + if (!in_dev) {
> rcu_read_unlock();
> return;
> }
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" 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] 20+ messages in thread
* Re: [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init()
2017-05-22 16:37 ` [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() SF Markus Elfring
2017-05-22 19:51 ` Marcelo Ricardo Leitner
@ 2017-05-22 20:57 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Vlad Yasevich @ 2017-05-22 20:57 UTC (permalink / raw)
To: SF Markus Elfring, linux-sctp, netdev, David S. Miller,
Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
On 05/22/2017 12:37 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 17:20:11 +0200
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> * Replace the specification of a data structure by a pointer dereference
> to make the corresponding size determination a bit safer according to
> the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
-vlad
> ---
> net/sctp/protocol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 989a900383b5..2b1a6215bd2f 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1442,6 +1442,6 @@ static __init int sctp_init(void)
>
> /* Allocate and initialize the endpoint hash table. */
> sctp_ep_hashsize = 64;
> - sctp_ep_hashtable =
> - kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL);
> + sctp_ep_hashtable = kmalloc_array(64, sizeof(*sctp_ep_hashtable),
> + GFP_KERNEL);
> if (!sctp_ep_hashtable) {
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] sctp: Delete an error message for a failed memory allocation in sctp_init()
2017-05-22 16:38 ` [PATCH 2/5] sctp: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-05-22 16:56 ` Marcelo Ricardo Leitner
2017-05-22 19:52 ` Marcelo Ricardo Leitner
@ 2017-05-22 20:59 ` Vlad Yasevich
2 siblings, 0 replies; 20+ messages in thread
From: Vlad Yasevich @ 2017-05-22 20:59 UTC (permalink / raw)
To: SF Markus Elfring, linux-sctp, netdev, David S. Miller,
Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
On 05/22/2017 12:38 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 17:28:14 +0200
>
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> net/sctp/protocol.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 2b1a6215bd2f..5e7c8a344770 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1447,5 +1447,4 @@ static __init int sctp_init(void)
> if (!sctp_ep_hashtable) {
> - pr_err("Failed endpoint_hash alloc\n");
> status = -ENOMEM;
> goto err_ehash_alloc;
> }
>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
At the time this was written, it was patterned after TCP. Since then TCP changed
significantly. We can surely clean-up the pr_err() here and possibly update the
code as well later.
-vlad
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] sctp: Fix a typo in a comment line in sctp_init()
2017-05-22 16:39 ` [PATCH 3/5] sctp: Fix a typo in a comment line " SF Markus Elfring
2017-05-22 19:52 ` Marcelo Ricardo Leitner
@ 2017-05-22 21:00 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Vlad Yasevich @ 2017-05-22 21:00 UTC (permalink / raw)
To: SF Markus Elfring, linux-sctp, netdev, David S. Miller,
Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
On 05/22/2017 12:39 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 17:43:44 +0200
>
> Add a missing character in this description.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> net/sctp/protocol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 5e7c8a344770..64756c42cec9 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -1454,7 +1454,7 @@ static __init int sctp_init(void)
> }
>
> /* Allocate and initialize the SCTP port hash table.
> - * Note that order is initalized to start at the max sized
> + * Note that order is initialized to start at the max sized
> * table we want to support. If we can't get that many pages
> * reduce the order and try again
> */
>
Acked-by: Vlad Yasevich <vyasevich@gmail.com.
-vlad
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event()
2017-05-22 16:40 ` [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event() SF Markus Elfring
2017-05-22 19:52 ` Marcelo Ricardo Leitner
@ 2017-05-22 21:00 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Vlad Yasevich @ 2017-05-22 21:00 UTC (permalink / raw)
To: SF Markus Elfring, linux-sctp, netdev, David S. Miller,
Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
On 05/22/2017 12:40 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 18:08:24 +0200
>
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> net/sctp/protocol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 64756c42cec9..057479b7bd72 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -784,7 +784,7 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
>
> switch (ev) {
> case NETDEV_UP:
> - addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
> + addr = kmalloc(sizeof(*addr), GFP_ATOMIC);
> if (addr) {
> addr->a.v4.sin_family = AF_INET;
> addr->a.v4.sin_port = 0;
>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
-vlad
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 5/5] sctp: Adjust one function call together with a variable assignment
2017-05-22 16:41 ` [PATCH 5/5] sctp: Adjust one function call together with a variable assignment SF Markus Elfring
2017-05-22 19:53 ` Marcelo Ricardo Leitner
@ 2017-05-22 21:00 ` Vlad Yasevich
1 sibling, 0 replies; 20+ messages in thread
From: Vlad Yasevich @ 2017-05-22 21:00 UTC (permalink / raw)
To: SF Markus Elfring, linux-sctp, netdev, David S. Miller,
Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
On 05/22/2017 12:41 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 18:15:12 +0200
>
> The script "checkpatch.pl" pointed information out like the following.
>
> ERROR: do not use assignment in if condition
>
> Thus fix the affected source code place.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> net/sctp/protocol.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
> index 057479b7bd72..be2fe3ebae78 100644
> --- a/net/sctp/protocol.c
> +++ b/net/sctp/protocol.c
> @@ -141,7 +141,8 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
> struct sctp_sockaddr_entry *addr;
>
> rcu_read_lock();
> - if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
> + in_dev = __in_dev_get_rcu(dev);
> + if (!in_dev) {
> rcu_read_unlock();
> return;
> }
>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
-vlad
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/5] net-SCTP: Adjustments for three function implementations
2017-05-22 16:35 [PATCH 0/5] net-SCTP: Adjustments for three function implementations SF Markus Elfring
` (4 preceding siblings ...)
2017-05-22 16:41 ` [PATCH 5/5] sctp: Adjust one function call together with a variable assignment SF Markus Elfring
@ 2017-05-23 6:34 ` Xin Long
5 siblings, 0 replies; 20+ messages in thread
From: Xin Long @ 2017-05-23 6:34 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, network dev, David S. Miller, Neil Horman,
Vlad Yasevich, LKML, kernel-janitors
On Tue, May 23, 2017 at 12:35 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 18:30:45 +0200
>
> A few update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (5):
> Use kmalloc_array() in sctp_init()
> Delete an error message for a failed memory allocation in sctp_init()
> Fix a typo in a comment line in sctp_init()
> Improve a size determination in sctp_inetaddr_event()
> Adjust one function call together with a variable assignment
>
> net/sctp/protocol.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
I guess these patches are for net-next.git
Series Reviewed-by: Xin Long <lucien.xin@gmail.com>
>
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" 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] 20+ messages in thread
end of thread, other threads:[~2017-05-23 6:34 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 16:35 [PATCH 0/5] net-SCTP: Adjustments for three function implementations SF Markus Elfring
2017-05-22 16:37 ` [PATCH 1/5] sctp: Use kmalloc_array() in sctp_init() SF Markus Elfring
2017-05-22 19:51 ` Marcelo Ricardo Leitner
2017-05-22 20:57 ` Vlad Yasevich
2017-05-22 16:38 ` [PATCH 2/5] sctp: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-05-22 16:56 ` Marcelo Ricardo Leitner
2017-05-22 19:46 ` SF Markus Elfring
2017-05-22 19:50 ` Marcelo Ricardo Leitner
2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 20:59 ` Vlad Yasevich
2017-05-22 16:39 ` [PATCH 3/5] sctp: Fix a typo in a comment line " SF Markus Elfring
2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
2017-05-22 16:40 ` [PATCH 4/5] sctp: Improve a size determination in sctp_inetaddr_event() SF Markus Elfring
2017-05-22 19:52 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
2017-05-22 16:41 ` [PATCH 5/5] sctp: Adjust one function call together with a variable assignment SF Markus Elfring
2017-05-22 19:53 ` Marcelo Ricardo Leitner
2017-05-22 21:00 ` Vlad Yasevich
2017-05-23 6:34 ` [PATCH 0/5] net-SCTP: Adjustments for three function implementations Xin Long
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).