From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EC38345CD8; Mon, 18 Nov 2024 19:23:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF74A432D2; Mon, 18 Nov 2024 19:22:28 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id E3F5B42D89 for ; Mon, 18 Nov 2024 19:22:18 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7ea9739647bso15787a12.0 for ; Mon, 18 Nov 2024 10:22:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731954138; x=1732558938; darn=dpdk.org; 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=IxOovxIOewAlfR9Uj7H8w0Sa+8B1HT5jxe8yQFkXhs0=; b=zd0WsXyouD35+81Qb7yS2/SeQF3IjH2hcBVWaDzSUqbZ1KEJORD6Y8lvjgVT+t3eM1 icQlUEHKEaWtWlXiBFg+AxsjiDNUJ8um/z/BrjHyknUAD7AUqxpCbobug4TTMEgiiAmq 3PA6zkfeKerU6xchFnc7hlT9Upvu16EWe0SfYplVMtumMw2n3xJlTRNKVN/jKUXPVkYJ q7Q+jBH5rlFr9JElw4MbXj87ZNExYVUBDVz/AABRK2UcDrW+QmYWHVLVwGUU9UXcoKtk lt0EyPkN9mZQXc8cYPAVFJLP81gWu1OkS5/IS9up0Nknocis8EMSze1AckVppvimPhPT Q0IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731954138; x=1732558938; 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=IxOovxIOewAlfR9Uj7H8w0Sa+8B1HT5jxe8yQFkXhs0=; b=aeYoecgZ9DatJNQXSSUfNRP6MGg4GzoGQFvSx/DmnSLGUsejcl+9EmRn5ahBlpoBdu 4I+1ImVaAUdxga0nIUIZFaN7q9hfPN0q502tfGizk2v4dzTfQmDrDn3UQxVjckpZeaCv xcM4hROz8kJSnjh6JHnEyE5bdeLSoB07bWj7+JquJ86shR6QYCcz24p/M49lQ5Vv4ylM ZfE50K3dxdGlwBd2NFuQ8HJer8yqtv5X3S53GOvOlMahW/wbTiD89Wa//ysyzvb/ZrPw aqixXg7M9f3KpwZrZuajaPL0lA6IPfrSzGa/GAR2qYLHrpGiVWu0iHLz22eTNM5dkp9+ 7jlw== X-Gm-Message-State: AOJu0YwUgDH90qOs0nvQp3Jtq+iSP8vj+RNWwMYZvBhVdMp3fioxalEC UPs68RMKuCMAsOku1+IhOGs/rwUqYFQeYHyWUhUU5VE45BJxG/3rivW11s44bjTZJ+LXBT6X48U 3 X-Google-Smtp-Source: AGHT+IHrg9vsAwttHWmkFKZfF6Cuntp6LJQrf8OsZbn301A66i815JF5HtGASUtvBBP94NH43FGOtQ== X-Received: by 2002:a17:90a:d40f:b0:2ea:a25d:3bc1 with SMTP id 98e67ed59e1d1-2eaa25d3cc4mr1543415a91.28.1731954138163; Mon, 18 Nov 2024 10:22:18 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea61869bb2sm2916724a91.12.2024.11.18.10.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 10:22:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , tduszynski@marvell.com Subject: [PATCH v2 19/19] common/cnxk: fix null ptr check Date: Mon, 18 Nov 2024 10:21:00 -0800 Message-ID: <20241118182153.87042-20-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182153.87042-1-stephen@networkplumber.org> References: <20241115060738.313190-1-stephen@networkplumber.org> <20241118182153.87042-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The pointer mode is used then checked which is a bug reported by PVS studio and Coverity. Fixes: bd2fd34ab86f ("common/cnxk: sync eth mode change command with firmware") Cc: tduszynski@marvell.com Signed-off-by: Stephen Hemminger --- drivers/common/cnxk/roc_bphy_cgx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/common/cnxk/roc_bphy_cgx.c b/drivers/common/cnxk/roc_bphy_cgx.c index 4f43605e10..6e5cfc7b1d 100644 --- a/drivers/common/cnxk/roc_bphy_cgx.c +++ b/drivers/common/cnxk/roc_bphy_cgx.c @@ -369,20 +369,20 @@ roc_bphy_cgx_set_link_mode(struct roc_bphy_cgx *roc_cgx, unsigned int lmac, { uint64_t scr1, scr0; + if (!mode) + return -EINVAL; + + if (!roc_cgx) + return -EINVAL; + if (roc_model_is_cn9k() && (mode->use_portm_idx || mode->portm_idx || mode->mode_group_idx)) { return -ENOTSUP; } - if (!roc_cgx) - return -EINVAL; - if (!roc_bphy_cgx_lmac_exists(roc_cgx, lmac)) return -ENODEV; - if (!mode) - return -EINVAL; - scr1 = FIELD_PREP(SCR1_ETH_CMD_ID, ETH_CMD_MODE_CHANGE) | FIELD_PREP(SCR1_ETH_MODE_CHANGE_ARGS_SPEED, mode->speed) | FIELD_PREP(SCR1_ETH_MODE_CHANGE_ARGS_DUPLEX, mode->full_duplex) | -- 2.45.2