Commit 6fdfdef7 authored by Alexey Kodanev's avatar Alexey Kodanev Committed by Jakub Kicinski

sctp: remove unnecessary NULL check in sctp_association_init()

'&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: default avatarAlexey Kodanev <aleksei.kodanev@bell-sw.com>
Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
Link: https://lore.kernel.org/r/20221019180735.161388-1-aleksei.kodanev@bell-sw.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 94adb5e2
...@@ -35,8 +35,7 @@ struct sctp_ulpq { ...@@ -35,8 +35,7 @@ struct sctp_ulpq {
}; };
/* Prototypes. */ /* Prototypes. */
struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *, void sctp_ulpq_init(struct sctp_ulpq *ulpq, struct sctp_association *asoc);
struct sctp_association *);
void sctp_ulpq_flush(struct sctp_ulpq *ulpq); void sctp_ulpq_flush(struct sctp_ulpq *ulpq);
void sctp_ulpq_free(struct sctp_ulpq *); void sctp_ulpq_free(struct sctp_ulpq *);
......
...@@ -226,8 +226,7 @@ static struct sctp_association *sctp_association_init( ...@@ -226,8 +226,7 @@ static struct sctp_association *sctp_association_init(
/* Create an output queue. */ /* Create an output queue. */
sctp_outq_init(asoc, &asoc->outqueue); sctp_outq_init(asoc, &asoc->outqueue);
if (!sctp_ulpq_init(&asoc->ulpq, asoc)) sctp_ulpq_init(&asoc->ulpq, asoc);
goto fail_init;
if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams, 0, gfp)) if (sctp_stream_init(&asoc->stream, asoc->c.sinit_num_ostreams, 0, gfp))
goto stream_free; goto stream_free;
...@@ -277,7 +276,6 @@ static struct sctp_association *sctp_association_init( ...@@ -277,7 +276,6 @@ static struct sctp_association *sctp_association_init(
stream_free: stream_free:
sctp_stream_free(&asoc->stream); sctp_stream_free(&asoc->stream);
fail_init:
sock_put(asoc->base.sk); sock_put(asoc->base.sk);
sctp_endpoint_put(asoc->ep); sctp_endpoint_put(asoc->ep);
return NULL; return NULL;
......
...@@ -38,8 +38,7 @@ static void sctp_ulpq_reasm_drain(struct sctp_ulpq *ulpq); ...@@ -38,8 +38,7 @@ static void sctp_ulpq_reasm_drain(struct sctp_ulpq *ulpq);
/* 1st Level Abstractions */ /* 1st Level Abstractions */
/* Initialize a ULP queue from a block of memory. */ /* Initialize a ULP queue from a block of memory. */
struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *ulpq, void sctp_ulpq_init(struct sctp_ulpq *ulpq, struct sctp_association *asoc)
struct sctp_association *asoc)
{ {
memset(ulpq, 0, sizeof(struct sctp_ulpq)); memset(ulpq, 0, sizeof(struct sctp_ulpq));
...@@ -48,8 +47,6 @@ struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *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->reasm_uo);
skb_queue_head_init(&ulpq->lobby); skb_queue_head_init(&ulpq->lobby);
ulpq->pd_mode = 0; ulpq->pd_mode = 0;
return ulpq;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment