From patchwork Wed Sep 1 09:43:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyunjian X-Patchwork-Id: 1523011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gzzdv62C6z9sf8 for ; Wed, 1 Sep 2021 19:43:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C4AE9824E3; Wed, 1 Sep 2021 09:43:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aTQaMR6ThC2w; Wed, 1 Sep 2021 09:43:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1690980E5E; Wed, 1 Sep 2021 09:43:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EA0DFC001A; Wed, 1 Sep 2021 09:43:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 313CEC000E for ; Wed, 1 Sep 2021 09:43:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 21E0C606CB for ; Wed, 1 Sep 2021 09:43:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YBcKFydC90Ml for ; Wed, 1 Sep 2021 09:43:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by smtp3.osuosl.org (Postfix) with ESMTPS id 3805060666 for ; Wed, 1 Sep 2021 09:43:37 +0000 (UTC) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GzzXl4NP3z8vtS; Wed, 1 Sep 2021 17:39:19 +0800 (CST) Received: from dggpemm500008.china.huawei.com (7.185.36.136) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 1 Sep 2021 17:43:34 +0800 Received: from localhost (10.174.242.157) by dggpemm500008.china.huawei.com (7.185.36.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 1 Sep 2021 17:43:33 +0800 From: Yunjian Wang To: , Date: Wed, 1 Sep 2021 17:43:32 +0800 Message-ID: <1630489412-31008-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.174.242.157] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500008.china.huawei.com (7.185.36.136) X-CFilter-Loop: Reflected Cc: dingxiaoxiong@huawei.com Subject: [ovs-dev] [PATCH] bond: Fix return value check in bond_member_set_may_enable() X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The function bond_member_lookup() could return NULL, the return value need to be checked. Addresses-Coverity: ("Dereference null return value") Signed-off-by: Yunjian Wang Acked-by: Kevin Traynor --- ofproto/bond.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ofproto/bond.c b/ofproto/bond.c index a4116588f..2dcfeda71 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -672,8 +672,13 @@ out: void bond_member_set_may_enable(struct bond *bond, void *member_, bool may_enable) { + struct bond_member *member; + ovs_rwlock_wrlock(&rwlock); - bond_member_lookup(bond, member_)->may_enable = may_enable; + member = bond_member_lookup(bond, member_); + if (member) { + member->may_enable = may_enable; + } ovs_rwlock_unlock(&rwlock); }