From patchwork Wed Oct 19 18:07:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 13012251 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A236CC43217 for ; Wed, 19 Oct 2022 18:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbiJSSUK (ORCPT ); Wed, 19 Oct 2022 14:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbiJSSUI (ORCPT ); Wed, 19 Oct 2022 14:20:08 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62212FE90E for ; Wed, 19 Oct 2022 11:20:06 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id m23so23259906lji.2 for ; Wed, 19 Oct 2022 11:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bell-sw-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=leGn7lYjbLsCg1ruqtqQzH3i7rIADWTNWm3R6efH+Ts=; b=7IMbgOWr9aX9zK5Gxu2eiIoyOQgBCov0/9e28ADabZ3kz3vPaWWdtsE+KfmsirwNvl zgUIplAyFVcrnBWhQTzxiQCQ5RNvRe4LVUTu07lLWMdPuEIIbs5poPXVzViwe2PopWx+ S2NRQv7xQAFbETr0CdzZhn2GxhmlookCSnrQO44Y+m83BoBVRuevSeQe9igJaNwIwn7x 7A6EqMLIT7TmlbGTKqSvOQzt6Kg6NbFstn1GeA8iyzksyzwbB0aD0WOIDJDQM0UsIZOo t6t+w0m64sQCLVtq9fFUBeE7oYsc3dkap77omRWFLAxj2z1vF/6pDJLo9a/SZNgzeBgg r3SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=leGn7lYjbLsCg1ruqtqQzH3i7rIADWTNWm3R6efH+Ts=; b=5Yd4FWsaS+iD9fcx1JYXVuhDTO20lPyKZECAlxmuKAyExV3NKjbi1NFNCrB2D78Ih1 QrmAZekx+AMkXIN8M9DIr25dSk/N0YzBq71su2Lb0CA1E2RUmn2feyQPdxhUSODQZb68 V1+JafgJKJPvA5zLg50tjnm7qih7gt3d9hMmx/cAZa0svjn7SprHAXrXpawA/8SNGjgO OmtmRJGk9QrpAWRfgEc4itfvN3vRBOZpaw3s2Ze23uShozYv9Wfw+XcY/8obr98O3SVQ NpIOWcy3Y4qR/Ld4/UYMculWEgl+J4CqTBdRJl4/pJrr/berXBm4cDS5DdNoTM/zDSLa N5yw== X-Gm-Message-State: ACrzQf3/x+4ZcW9bEbf8xRFMoM177Zyq9bDEZxpvucbyaxtKz/L4epRq hvzk55z8FBRf3WqQTwTKbg1HTQ7NdoIp X-Google-Smtp-Source: AMsMyM45OeAzmZdMMd1kOsatYDjpF1Y4iE+YzFMV4oKRPzAYmMm4brFEHSt1lAOQkCcJAfznHbYpHg== X-Received: by 2002:a2e:7019:0:b0:26f:a8a3:81de with SMTP id l25-20020a2e7019000000b0026fa8a381demr3348187ljc.530.1666203604024; Wed, 19 Oct 2022 11:20:04 -0700 (PDT) Received: from localhost.localdomain ([95.161.223.113]) by smtp.gmail.com with ESMTPSA id j23-20020ac24557000000b004a287c50c13sm2389916lfm.185.2022.10.19.11.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 11:20:03 -0700 (PDT) From: Alexey Kodanev To: linux-sctp@vger.kernel.org Cc: netdev@vger.kernel.org, Alexey Kodanev Subject: [PATCH net-next 1/3] sctp: remove unnecessary NULL check in sctp_association_init() Date: Wed, 19 Oct 2022 21:07:33 +0300 Message-Id: <20221019180735.161388-1-aleksei.kodanev@bell-sw.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org '&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 Reviewed-by: Xin Long --- 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; } From patchwork Wed Oct 19 18:07:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 13012252 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C541C4321E for ; Wed, 19 Oct 2022 18:20:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbiJSSUL (ORCPT ); Wed, 19 Oct 2022 14:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230474AbiJSSUI (ORCPT ); Wed, 19 Oct 2022 14:20:08 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5AFF10250C for ; Wed, 19 Oct 2022 11:20:06 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id b18so23243335ljr.13 for ; Wed, 19 Oct 2022 11:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bell-sw-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fPh0u1BA0HQYxCfyWKJVzP0srDWIxJF+kLpCjGoUg78=; b=hEmS6GbI/1koN1G+CUVRnXrQLIwK/YMFTK3pq8IiQWlcOPyHOhGlqLkJSIsJ4pkJ5W kAFJ0Jtbai2QkstEWnIVaIUQAX6bvpLh/eDBWrqeZLB93CuSAXfWNxrHdEPx36f3oW6d UCSuzaNSu/yxSkIpkpGuyurdvv2y1XinbpD8yqb9kCxk5dmKE3cNBQeMhBHX+cxUqpMP 88LCSe9jkw6y6AMcqP0m6uROGOEr+xPZPa0RO2UchKhFc0FD2ON2uMTUnRK6klnxm12X 4X8W8PbEKD+SFHp1NjUTOYOMxI5TWMeQL0QuIKyYWD/dvvtBnGS+kCnXsHOKGO7TfRvz ocxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fPh0u1BA0HQYxCfyWKJVzP0srDWIxJF+kLpCjGoUg78=; b=WRh44zqEdEIzdRM0CI9lYEvWwoAgVPvVdGeWGfAON5ZAvPFF146l8VPyQvsCAHA9Cs nWHoFZpe3Jo9vV3Pv/EzhJTwSNRJyub7AUjsU0ldbkNiVMhvdWdQ4fnDTULIqXF44YP3 OJoqj0PBXDKO8jhn1HV5WyIhQNd8vgSSWlSsgwoNRozRZXTDoo6k2C8GoMezgHQwZO5w 5M5RFq/yv/mzEO9jPE5T7IjrOkyL2VsxG9TdZFB5HUchY3xR3iBWvoIQmnh549MOGinD AaQr966zaFdrZMEGBSh6vmhMvQ9Is4Ntav8QDfYiICon5TiRKeBSPyPW/w7i1ZPiJQ+l uL1A== X-Gm-Message-State: ACrzQf1pOJCO9XgV7BsxC7tPCUaLEIoH/84V+3QqVVwdQ7iPqjDLgwJh f82Xpx9kkfJzr5hkpQ7Gmqnq X-Google-Smtp-Source: AMsMyM6NrfkHk+sR1M8XdMNeQ79MLvygM8kM/P9L44tE14vUcD3bKlRvYQKPjcfc3RdvCsrEkI31Uw== X-Received: by 2002:a2e:88c2:0:b0:26e:2a8:d6a1 with SMTP id a2-20020a2e88c2000000b0026e02a8d6a1mr3393053ljk.131.1666203604807; Wed, 19 Oct 2022 11:20:04 -0700 (PDT) Received: from localhost.localdomain ([95.161.223.113]) by smtp.gmail.com with ESMTPSA id j23-20020ac24557000000b004a287c50c13sm2389916lfm.185.2022.10.19.11.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 11:20:04 -0700 (PDT) From: Alexey Kodanev To: linux-sctp@vger.kernel.org Cc: netdev@vger.kernel.org, Alexey Kodanev Subject: [PATCH net-next 2/3] sctp: remove unnecessary NULL check in sctp_ulpq_tail_event() Date: Wed, 19 Oct 2022 21:07:34 +0300 Message-Id: <20221019180735.161388-2-aleksei.kodanev@bell-sw.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019180735.161388-1-aleksei.kodanev@bell-sw.com> References: <20221019180735.161388-1-aleksei.kodanev@bell-sw.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Xin Long --- 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; } From patchwork Wed Oct 19 18:07:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 13012253 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6DD7C4332F for ; Wed, 19 Oct 2022 18:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230496AbiJSSUN (ORCPT ); Wed, 19 Oct 2022 14:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbiJSSUJ (ORCPT ); Wed, 19 Oct 2022 14:20:09 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65097105368 for ; Wed, 19 Oct 2022 11:20:07 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id by36so23267367ljb.4 for ; Wed, 19 Oct 2022 11:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bell-sw-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GdMe4wNLlPasVGo4Wb6xEZk50ae59ENm+PGbWOO1sik=; b=wEhRvLVVZEBCd5wkc5IQBPn0f047oHR5qiQtC5mDtGtN0eXPqe5Y6TCjm+87hoPEqY UzoLnxtkPfzHq6cGsUGgPih1LRrDamQT5y0L04jA8nFy5m7nnH7ub/gde8+AW4MOkNo2 8Cw3klgCQgMyR/0gPbl/xElZb6S/suy5cUENQq3FCzBn3FH60KQ0lS2ta8iWiSLvAREv QLzjxBRa2PX7Qk4bMu8axOvIgsgjXnfQW4b6GPGsAd2K8slL4HxWEa1nujzzpgjpsLpA 9OFjeW2Hpyfqpgzh5KPxnAEjC+y+n3Zsw/86ZApNvbRSb5wx4yT/eLj10lfHYjrNcmxE BL0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GdMe4wNLlPasVGo4Wb6xEZk50ae59ENm+PGbWOO1sik=; b=vYBA+v+D9leO1ZMTXr0PrFqMVYPxcRQT6T4NvoXVaZ6ZV5/pHIHrJgHcFP2Z5sm+lx gyuEoZzcmAAbmAuRmSxbFnUHYFxxjg53Hfz4hZcgADZgs8Ped8Ncq5yzSS+xqkbgi/we Y8ck/BE0pcHwnre1MForICx7Ohev/d2ynHHnU9xLDjcJ0LM6NjPJmufjFDM2wKcDhdmp ygaJoDgaU0g7QT103WP9DJILeaj//FXlg22GNTuKZ0Opb/pv+nUSpHIp1N36FOH0lb/x M8f06W3du2pkKQGjzgSDvUQnUZYw0JdYRE/HDrXaXYqx3wOQCAve5BFIQJQjFEsqXVTE MwgQ== X-Gm-Message-State: ACrzQf09I7lP3Q6tGseF8NXPj6XQR7khjS1GZkK76ljRgY15jzeUS+HZ fxH8Wbfd9tijidi07i4zayLb X-Google-Smtp-Source: AMsMyM7fUlk+9j02IdUBW1dVtCtdvm2N294zOE1+6/rsqQUY4kzQ1RcCT9GNGF/YGNF2Gty6jWU52w== X-Received: by 2002:a05:651c:1609:b0:26e:93e8:b6e with SMTP id f9-20020a05651c160900b0026e93e80b6emr3605472ljq.456.1666203605608; Wed, 19 Oct 2022 11:20:05 -0700 (PDT) Received: from localhost.localdomain ([95.161.223.113]) by smtp.gmail.com with ESMTPSA id j23-20020ac24557000000b004a287c50c13sm2389916lfm.185.2022.10.19.11.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 11:20:05 -0700 (PDT) From: Alexey Kodanev To: linux-sctp@vger.kernel.org Cc: netdev@vger.kernel.org, Alexey Kodanev Subject: [PATCH net-next 3/3] sctp: remove unnecessary NULL checks in sctp_enqueue_event() Date: Wed, 19 Oct 2022 21:07:35 +0300 Message-Id: <20221019180735.161388-3-aleksei.kodanev@bell-sw.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019180735.161388-1-aleksei.kodanev@bell-sw.com> References: <20221019180735.161388-1-aleksei.kodanev@bell-sw.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Xin Long --- 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; }