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 006F042818; Thu, 23 Mar 2023 02:04:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 577B742B7E; Thu, 23 Mar 2023 02:04:36 +0100 (CET) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id 7825D40156 for ; Thu, 23 Mar 2023 02:04:33 +0100 (CET) Received: by mail-pj1-f41.google.com with SMTP id gp15-20020a17090adf0f00b0023d1bbd9f9eso440233pjb.0 for ; Wed, 22 Mar 2023 18:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1679533472; 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=U3IiaJ6iorHjs4QPlytaj/B4WMfxH5xIZPxFdJ7qFBg=; b=ag6ECaqxV9QuJ8c9pM2tZBcNhMaXCnihWLqgVNTLjdtmwbbEPfkEUbvjKrpd4P838r N1AQJmgbx5EnYoTRD8FvrZMZuKuc89W/ZDBPadGM6Ajkpk2jaFCD6Hq2FcBgn91/YAIo QJGm41j9OMrOd5dggKS/ewwKfRPPEw82wNchpuHIbKRt7x31PHDTdLv/sk5cZmY7Sbg6 a3LBjbvs+2z5jiRcs2SILUAm5OvihICa1B0woBrM7rn+nrC+PnVbMevnQSBhwq6Kwc4y 6ALKFgHXaWm2DCCkDOaQNkPM27gdqIgDGTSUkYXt0jcfvbULGwzw01NL/5CQ6AkVpU04 An1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679533472; 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=U3IiaJ6iorHjs4QPlytaj/B4WMfxH5xIZPxFdJ7qFBg=; b=XTPtSD/SDBdQJyibt+TtIdTWY9X1V7S0FttvEcTsnBJOa9ah8g1EPaKzR6RvXUGtrf jOWo8/Z5kPqgpMHJ9megZNW5OE+GdznqilVHMS4HE8Yw0xdKp3AF4DcRBLhAZWv5pnj4 yQC9rphHUsdSNUVEV1dthBynP6bj62dCQaFggSEEMJuI5WnbsrVqn47IhTgJW4vZ262/ KX/q6hvRwwlM/5qlUN0M8R8myAq9ccSnG/U5hB4FXi6YA2Iom5yXA6Rpk+EBNXhU7i4a dyjGK+kgp9x5Fv1o9QWAu1o++Xal8rLZM2Px73nWWM2HdbslNirgHsOFVwZ59oO8WXB8 3uhQ== X-Gm-Message-State: AO0yUKWu/r8aL42nXWcd8bN5JRaHOU1qwfKrQpbGISMlsUhuRg9TYcTs sp1fB/LF3nKX7ItIaBaq3NaqGVqdw9ftJw4wO0OazQ== X-Google-Smtp-Source: AK7set8olVALXAhXshv/Of8oOc793ww1bN31VOKOaZMYeKzlEsC5lu0E1RVyvdpklVDo1DBeGqyUkA== X-Received: by 2002:a17:90b:3805:b0:23d:3f32:1cd5 with SMTP id mq5-20020a17090b380500b0023d3f321cd5mr5445359pjb.26.1679533472391; Wed, 22 Mar 2023 18:04:32 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l9-20020a17090b078900b0023b4c0ef8f2sm135206pjz.20.2023.03.22.18.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 18:04:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Srikanth Yalavarthi Subject: [PATCH 2/4] ml/cnkx: remove unnecessary null checks Date: Wed, 22 Mar 2023 18:04:26 -0700 Message-Id: <20230323010428.64020-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323010428.64020-1-stephen@networkplumber.org> References: <20230323010428.64020-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 These are places where null check is not necessary before calling free. Signed-off-by: Stephen Hemminger --- drivers/ml/cnxk/cn10k_ml_dev.c | 9 +++------ drivers/ml/cnxk/cn10k_ml_ops.c | 12 ++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/ml/cnxk/cn10k_ml_dev.c b/drivers/ml/cnxk/cn10k_ml_dev.c index bba3c9022e6b..983138a7f237 100644 --- a/drivers/ml/cnxk/cn10k_ml_dev.c +++ b/drivers/ml/cnxk/cn10k_ml_dev.c @@ -319,8 +319,7 @@ cn10k_mldev_parse_devargs(struct rte_devargs *devargs, struct cn10k_ml_dev *mlde plt_info("ML: %s = %d", CN10K_ML_OCM_PAGE_SIZE, mldev->ocm_page_size); exit: - if (kvlist) - rte_kvargs_free(kvlist); + rte_kvargs_free(kvlist); return ret; } @@ -795,8 +794,7 @@ cn10k_ml_fw_load(struct cn10k_ml_dev *mldev) mz = plt_memzone_reserve_aligned(FW_MEMZONE_NAME, mz_size, 0, ML_CN10K_ALIGN_SIZE); if (mz == NULL) { plt_err("plt_memzone_reserve failed : %s", FW_MEMZONE_NAME); - if (fw_buffer != NULL) - free(fw_buffer); + free(fw_buffer); return -ENOMEM; } fw->req = mz->addr; @@ -813,8 +811,7 @@ cn10k_ml_fw_load(struct cn10k_ml_dev *mldev) if (roc_env_is_emulator() || roc_env_is_hw()) { fw->data = PLT_PTR_ADD(mz->addr, sizeof(struct cn10k_ml_req)); ret = cn10k_ml_fw_load_cn10ka(fw, fw_buffer, fw_size); - if (fw_buffer != NULL) - free(fw_buffer); + free(fw_buffer); } else if (roc_env_is_asim()) { fw->data = NULL; ret = cn10k_ml_fw_load_asim(fw); diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c index 4df2ca0e8c26..b5eaa24e831c 100644 --- a/drivers/ml/cnxk/cn10k_ml_ops.c +++ b/drivers/ml/cnxk/cn10k_ml_ops.c @@ -845,11 +845,9 @@ cn10k_ml_dev_configure(struct rte_ml_dev *dev, const struct rte_ml_dev_config *c return 0; error: - if (dev->data->queue_pairs != NULL) - rte_free(dev->data->queue_pairs); + rte_free(dev->data->queue_pairs); - if (dev->data->models != NULL) - rte_free(dev->data->models); + rte_free(dev->data->models); return ret; } @@ -887,8 +885,7 @@ cn10k_ml_dev_close(struct rte_ml_dev *dev) } } - if (dev->data->models) - rte_free(dev->data->models); + rte_free(dev->data->models); /* Destroy all queue pairs */ for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { @@ -900,8 +897,7 @@ cn10k_ml_dev_close(struct rte_ml_dev *dev) } } - if (dev->data->queue_pairs) - rte_free(dev->data->queue_pairs); + rte_free(dev->data->queue_pairs); /* Unload firmware */ cn10k_ml_fw_unload(mldev); -- 2.39.2