* [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init()
@ 2022-10-19 18:07 Alexey Kodanev
2022-10-19 18:07 ` [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event() Alexey Kodanev
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Alexey Kodanev @ 2022-10-19 18:07 UTC (permalink / raw)
To: linux-sctp; +Cc: netdev, Alexey Kodanev
'&asoc->ulpq' passed to sctp_ulpq_init() as the first argument,
then sctp_qlpq_init() initializes it and eventually returns the
address of the struct member back. Therefore, in this case, the
return pointer cannot be NULL.
Moreover, it seems sctp_ulpq_init() has always been used only in
sctp_association_init(), so there's really no need to return ulpq
anymore.
Detected using the static analysis tool - Svace.
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
include/net/sctp/ulpqueue.h | 3 +--
net/sctp/associola.c | 4 +---
net/sctp/ulpqueue.c | 5 +----
3 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/include/net/sctp/ulpqueue.h b/include/net/sctp/ulpqueue.h
index 0eaf8650e3b2..60f6641290c3 100644
--- a/include/net/sctp/ulpqueue.h
+++ b/include/net/sctp/ulpqueue.h
@@ -35,8 +35,7 @@ struct sctp_ulpq {
};
/* Prototypes. */
-struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *,
- struct sctp_association *);
+void sctp_ulpq_init(struct sctp_ulpq *ulpq, struct sctp_association *asoc);
void sctp_ulpq_flush(struct sctp_ulpq *ulpq);
void sctp_ulpq_free(struct sctp_ulpq *);
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 3460abceba44..63ba5551c13f 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -226,8 +226,7 @@ static struct sctp_association *sctp_association_init(
/* Create an output queue. */
sctp_outq_init(asoc, &asoc->outqueue);
- if (!sctp_ulpq_init(&asoc->ulpq, asoc))
- goto fail_init;
+ sctp_ulpq_init(&asoc->ulpq, asoc);
if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams, 0, gfp))
goto stream_free;
@@ -277,7 +276,6 @@ static struct sctp_association *sctp_association_init(
stream_free:
sctp_stream_free(&asoc->stream);
-fail_init:
sock_put(asoc->base.sk);
sctp_endpoint_put(asoc->ep);
return NULL;
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 0a8510a0c5e6..24960dcb6a21 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -38,8 +38,7 @@ static void sctp_ulpq_reasm_drain(struct sctp_ulpq *ulpq);
/* 1st Level Abstractions */
/* Initialize a ULP queue from a block of memory. */
-struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *ulpq,
- struct sctp_association *asoc)
+void sctp_ulpq_init(struct sctp_ulpq *ulpq, struct sctp_association *asoc)
{
memset(ulpq, 0, sizeof(struct sctp_ulpq));
@@ -48,8 +47,6 @@ struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *ulpq,
skb_queue_head_init(&ulpq->reasm_uo);
skb_queue_head_init(&ulpq->lobby);
ulpq->pd_mode = 0;
-
- return ulpq;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event()
2022-10-19 18:07 [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Alexey Kodanev
@ 2022-10-19 18:07 ` Alexey Kodanev
2022-10-19 21:26 ` Xin Long
2022-10-19 18:07 ` [PATCH net-next 3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event() Alexey Kodanev
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Alexey Kodanev @ 2022-10-19 18:07 UTC (permalink / raw)
To: linux-sctp; +Cc: netdev, Alexey Kodanev
After commit 013b96ec6461 ("sctp: Pass sk_buff_head explicitly to
sctp_ulpq_tail_event().") there is one more unneeded check of
skb_list for NULL.
Detected using the static analysis tool - Svace.
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
net/sctp/ulpqueue.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 24960dcb6a21..b05daafd369a 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -256,10 +256,7 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sk_buff_head *skb_list)
return 1;
out_free:
- if (skb_list)
- sctp_queue_purge_ulpevents(skb_list);
- else
- sctp_ulpevent_free(event);
+ sctp_queue_purge_ulpevents(skb_list);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next 3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event()
2022-10-19 18:07 [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Alexey Kodanev
2022-10-19 18:07 ` [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event() Alexey Kodanev
@ 2022-10-19 18:07 ` Alexey Kodanev
2022-10-19 21:28 ` Xin Long
2022-10-19 21:25 ` [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Xin Long
2022-10-21 5:10 ` patchwork-bot+netdevbpf
3 siblings, 1 reply; 7+ messages in thread
From: Alexey Kodanev @ 2022-10-19 18:07 UTC (permalink / raw)
To: linux-sctp; +Cc: netdev, Alexey Kodanev
After commit 178ca044aa60 ("sctp: Make sctp_enqueue_event tak an
skb list."), skb_list cannot be NULL.
Detected using the static analysis tool - Svace.
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
net/sctp/stream_interleave.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/net/sctp/stream_interleave.c b/net/sctp/stream_interleave.c
index bb22b71df7a3..94727feb07b3 100644
--- a/net/sctp/stream_interleave.c
+++ b/net/sctp/stream_interleave.c
@@ -490,11 +490,8 @@ static int sctp_enqueue_event(struct sctp_ulpq *ulpq,
if (!sctp_ulpevent_is_enabled(event, ulpq->asoc->subscribe))
goto out_free;
- if (skb_list)
- skb_queue_splice_tail_init(skb_list,
- &sk->sk_receive_queue);
- else
- __skb_queue_tail(&sk->sk_receive_queue, skb);
+ skb_queue_splice_tail_init(skb_list,
+ &sk->sk_receive_queue);
if (!sp->data_ready_signalled) {
sp->data_ready_signalled = 1;
@@ -504,10 +501,7 @@ static int sctp_enqueue_event(struct sctp_ulpq *ulpq,
return 1;
out_free:
- if (skb_list)
- sctp_queue_purge_ulpevents(skb_list);
- else
- sctp_ulpevent_free(event);
+ sctp_queue_purge_ulpevents(skb_list);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init()
2022-10-19 18:07 [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Alexey Kodanev
2022-10-19 18:07 ` [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event() Alexey Kodanev
2022-10-19 18:07 ` [PATCH net-next 3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event() Alexey Kodanev
@ 2022-10-19 21:25 ` Xin Long
2022-10-21 5:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 7+ messages in thread
From: Xin Long @ 2022-10-19 21:25 UTC (permalink / raw)
To: Alexey Kodanev; +Cc: linux-sctp, netdev
On Wed, Oct 19, 2022 at 2:29 PM Alexey Kodanev
<aleksei.kodanev@bell-sw.com> wrote:
>
> '&asoc->ulpq' passed to sctp_ulpq_init() as the first argument,
> then sctp_qlpq_init() initializes it and eventually returns the
> address of the struct member back. Therefore, in this case, the
> return pointer cannot be NULL.
>
> Moreover, it seems sctp_ulpq_init() has always been used only in
> sctp_association_init(), so there's really no need to return ulpq
> anymore.
>
> Detected using the static analysis tool - Svace.
> Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
> ---
> include/net/sctp/ulpqueue.h | 3 +--
> net/sctp/associola.c | 4 +---
> net/sctp/ulpqueue.c | 5 +----
> 3 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/include/net/sctp/ulpqueue.h b/include/net/sctp/ulpqueue.h
> index 0eaf8650e3b2..60f6641290c3 100644
> --- a/include/net/sctp/ulpqueue.h
> +++ b/include/net/sctp/ulpqueue.h
> @@ -35,8 +35,7 @@ struct sctp_ulpq {
> };
>
> /* Prototypes. */
> -struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *,
> - struct sctp_association *);
> +void sctp_ulpq_init(struct sctp_ulpq *ulpq, struct sctp_association *asoc);
> void sctp_ulpq_flush(struct sctp_ulpq *ulpq);
> void sctp_ulpq_free(struct sctp_ulpq *);
>
> diff --git a/net/sctp/associola.c b/net/sctp/associola.c
> index 3460abceba44..63ba5551c13f 100644
> --- a/net/sctp/associola.c
> +++ b/net/sctp/associola.c
> @@ -226,8 +226,7 @@ static struct sctp_association *sctp_association_init(
> /* Create an output queue. */
> sctp_outq_init(asoc, &asoc->outqueue);
>
> - if (!sctp_ulpq_init(&asoc->ulpq, asoc))
> - goto fail_init;
> + sctp_ulpq_init(&asoc->ulpq, asoc);
>
> if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams, 0, gfp))
> goto stream_free;
> @@ -277,7 +276,6 @@ static struct sctp_association *sctp_association_init(
>
> stream_free:
> sctp_stream_free(&asoc->stream);
> -fail_init:
> sock_put(asoc->base.sk);
> sctp_endpoint_put(asoc->ep);
> return NULL;
> diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
> index 0a8510a0c5e6..24960dcb6a21 100644
> --- a/net/sctp/ulpqueue.c
> +++ b/net/sctp/ulpqueue.c
> @@ -38,8 +38,7 @@ static void sctp_ulpq_reasm_drain(struct sctp_ulpq *ulpq);
> /* 1st Level Abstractions */
>
> /* Initialize a ULP queue from a block of memory. */
> -struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *ulpq,
> - struct sctp_association *asoc)
> +void sctp_ulpq_init(struct sctp_ulpq *ulpq, struct sctp_association *asoc)
> {
> memset(ulpq, 0, sizeof(struct sctp_ulpq));
>
> @@ -48,8 +47,6 @@ struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *ulpq,
> skb_queue_head_init(&ulpq->reasm_uo);
> skb_queue_head_init(&ulpq->lobby);
> ulpq->pd_mode = 0;
> -
> - return ulpq;
> }
>
>
> --
> 2.25.1
>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event()
2022-10-19 18:07 ` [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event() Alexey Kodanev
@ 2022-10-19 21:26 ` Xin Long
0 siblings, 0 replies; 7+ messages in thread
From: Xin Long @ 2022-10-19 21:26 UTC (permalink / raw)
To: Alexey Kodanev; +Cc: linux-sctp, netdev
On Wed, Oct 19, 2022 at 2:33 PM Alexey Kodanev
<aleksei.kodanev@bell-sw.com> wrote:
>
> After commit 013b96ec6461 ("sctp: Pass sk_buff_head explicitly to
> sctp_ulpq_tail_event().") there is one more unneeded check of
> skb_list for NULL.
>
> Detected using the static analysis tool - Svace.
> Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
> ---
> net/sctp/ulpqueue.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
> index 24960dcb6a21..b05daafd369a 100644
> --- a/net/sctp/ulpqueue.c
> +++ b/net/sctp/ulpqueue.c
> @@ -256,10 +256,7 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sk_buff_head *skb_list)
> return 1;
>
> out_free:
> - if (skb_list)
> - sctp_queue_purge_ulpevents(skb_list);
> - else
> - sctp_ulpevent_free(event);
> + sctp_queue_purge_ulpevents(skb_list);
>
> return 0;
> }
> --
> 2.25.1
>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event()
2022-10-19 18:07 ` [PATCH net-next 3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event() Alexey Kodanev
@ 2022-10-19 21:28 ` Xin Long
0 siblings, 0 replies; 7+ messages in thread
From: Xin Long @ 2022-10-19 21:28 UTC (permalink / raw)
To: Alexey Kodanev; +Cc: linux-sctp, netdev
On Wed, Oct 19, 2022 at 2:36 PM Alexey Kodanev
<aleksei.kodanev@bell-sw.com> wrote:
>
> After commit 178ca044aa60 ("sctp: Make sctp_enqueue_event tak an
> skb list."), skb_list cannot be NULL.
>
> Detected using the static analysis tool - Svace.
> Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
> ---
> net/sctp/stream_interleave.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/net/sctp/stream_interleave.c b/net/sctp/stream_interleave.c
> index bb22b71df7a3..94727feb07b3 100644
> --- a/net/sctp/stream_interleave.c
> +++ b/net/sctp/stream_interleave.c
> @@ -490,11 +490,8 @@ static int sctp_enqueue_event(struct sctp_ulpq *ulpq,
> if (!sctp_ulpevent_is_enabled(event, ulpq->asoc->subscribe))
> goto out_free;
>
> - if (skb_list)
> - skb_queue_splice_tail_init(skb_list,
> - &sk->sk_receive_queue);
> - else
> - __skb_queue_tail(&sk->sk_receive_queue, skb);
> + skb_queue_splice_tail_init(skb_list,
> + &sk->sk_receive_queue);
>
> if (!sp->data_ready_signalled) {
> sp->data_ready_signalled = 1;
> @@ -504,10 +501,7 @@ static int sctp_enqueue_event(struct sctp_ulpq *ulpq,
> return 1;
>
> out_free:
> - if (skb_list)
> - sctp_queue_purge_ulpevents(skb_list);
> - else
> - sctp_ulpevent_free(event);
> + sctp_queue_purge_ulpevents(skb_list);
>
> return 0;
> }
> --
> 2.25.1
>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init()
2022-10-19 18:07 [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Alexey Kodanev
` (2 preceding siblings ...)
2022-10-19 21:25 ` [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Xin Long
@ 2022-10-21 5:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-21 5:10 UTC (permalink / raw)
To: Alexey Kodanev; +Cc: linux-sctp, netdev
Hello:
This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 19 Oct 2022 21:07:33 +0300 you wrote:
> '&asoc->ulpq' passed to sctp_ulpq_init() as the first argument,
> then sctp_qlpq_init() initializes it and eventually returns the
> address of the struct member back. Therefore, in this case, the
> return pointer cannot be NULL.
>
> Moreover, it seems sctp_ulpq_init() has always been used only in
> sctp_association_init(), so there's really no need to return ulpq
> anymore.
>
> [...]
Here is the summary with links:
- [net-next,1/3] sctp: remove unnecessary NULL check in sctp_association_init()
https://git.kernel.org/netdev/net-next/c/6fdfdef7fdb5
- [net-next,2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event()
https://git.kernel.org/netdev/net-next/c/b66aeddbe30c
- [net-next,3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event()
https://git.kernel.org/netdev/net-next/c/377eb9aab084
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-21 5:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 18:07 [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Alexey Kodanev
2022-10-19 18:07 ` [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event() Alexey Kodanev
2022-10-19 21:26 ` Xin Long
2022-10-19 18:07 ` [PATCH net-next 3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event() Alexey Kodanev
2022-10-19 21:28 ` Xin Long
2022-10-19 21:25 ` [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Xin Long
2022-10-21 5:10 ` patchwork-bot+netdevbpf
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.