From patchwork Mon Nov 9 13:59:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 11891579 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 X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B92DC4741F for ; Mon, 9 Nov 2020 13:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A6B92076E for ; Mon, 9 Nov 2020 13:59:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uheTqZt3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731296AbgKIN7l (ORCPT ); Mon, 9 Nov 2020 08:59:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729854AbgKIN7k (ORCPT ); Mon, 9 Nov 2020 08:59:40 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 797FEC0613CF; Mon, 9 Nov 2020 05:59:38 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id e7so8228542pfn.12; Mon, 09 Nov 2020 05:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gSYjZ1cUgOekEM7SwW9yeu6llfvLPIn9JJb6KN19b+0=; b=uheTqZt3G2+6GJj/cnThwf9U010w83aj61EMBOva7nathZ8x/txGFq9RJd7zy5O7q7 Z+qZveWsaJMx7KsOK8BCgsRr9Myqdh+/u3J9225VqAXndLlOSf3W0jhO3XBASTAN7gdW RyRm6KF5rY6emONkNlZRtKwm5EWhnhpLPg3NBtFbJ09MQusOUAd3uPRgMDrF4fGiVqIV Em0N3pqiUpDkxQgKxMqrH9W4PezYE3c5d5LixTPQh4NGjXRyKXPEJXyCuusXMbO4YZAw mmTQoO4ihtK6Ysm8eStgwwssoRRNxXaopu3jCWJpvhyzV1vXCFNvPEwj6qfM0XXHQePs ucKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gSYjZ1cUgOekEM7SwW9yeu6llfvLPIn9JJb6KN19b+0=; b=bCsQuA2DYlYSj7Sc5SZD2eDZfFHnyCFnLY+IqKun9DF8DXC+Y7O4jEQNBKQObsvLh5 NVX2moim0TTguzUec7wAmmy/IFmZqPYkbKkLPCv4qTIK/kMFFZs4QypUkAFE11jKpyJD ST50t9xx6Gzf9yJSkdb1GmLAs2sjahc1ko+p1W836gq2mzQ8pxPa4eYJWbIk40hNN/WN er7kVX8Z7wrAsLPmwZOOYSzSCFlU5pYOrpqql2r1m15Uz0ciZ6ldlVmtjLXCN1k0yJP4 hp75oyneEVhsWDDnDzfnsynuOLMEKs4b0EWbYUaxc6iQSASuMNl73pN3mH4xw/Xw5wUC kseg== X-Gm-Message-State: AOAM531Tl5HVFOsD5ydaMXSCNI5JjScvT3OvJ44QrDWCJoY3BdvZDaD9 fryguhVl/qACkUpjVKwLtZy65i7SKCvn8Q== X-Google-Smtp-Source: ABdhPJyfg6WaH76st17Ot4HhGAxk1PA0a1hNeb+g2YZFvH9jjh5LnZNprzZ3mGoKYIKRbp8mH0SqoQ== X-Received: by 2002:a17:90b:1642:: with SMTP id il2mr12300961pjb.81.1604930378160; Mon, 09 Nov 2020 05:59:38 -0800 (PST) Received: from localhost ([209.9.72.213]) by smtp.gmail.com with ESMTPSA id j12sm10422175pga.78.2020.11.09.05.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 05:59:37 -0800 (PST) From: Geliang Tang To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Jakub Kicinski , Paolo Abeni Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.01.org, linux-kernel@vger.kernel.org, Dan Carpenter Subject: [MPTCP][PATCH net 2/2] mptcp: cleanup for mptcp_pm_alloc_anno_list Date: Mon, 9 Nov 2020 21:59:22 +0800 Message-Id: <0f17d2f60c188554d093e820c45caf20fe53aab0.1604930005.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch added NULL pointer check for mptcp_pm_alloc_anno_list, and avoided similar static checker warnings in mptcp_pm_add_timer. Signed-off-by: Geliang Tang Reviewed-by: Dan Carpenter --- net/mptcp/pm_netlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 03f2c28f11f5..dfc1bed4a55f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -266,7 +266,9 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, { struct mptcp_pm_add_entry *add_entry = NULL; struct sock *sk = (struct sock *)msk; - struct net *net = sock_net(sk); + + if (!msk) + return false; if (lookup_anno_list_by_saddr(msk, &entry->addr)) return false; @@ -283,7 +285,7 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, timer_setup(&add_entry->add_timer, mptcp_pm_add_timer, 0); sk_reset_timer(sk, &add_entry->add_timer, - jiffies + mptcp_get_add_addr_timeout(net)); + jiffies + mptcp_get_add_addr_timeout(sock_net(sk))); return true; }