From patchwork Thu Jun 11 21:37:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 71289 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D0191A00BE; Thu, 11 Jun 2020 23:38:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CC32129CB; Thu, 11 Jun 2020 23:38:14 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 123D31252 for ; Thu, 11 Jun 2020 23:38:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591911492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CzG2L0odJaE6ntRCoK6uUQjvvdIhbOutSlFFUrSsQOk=; b=De4m5IXXvdSljE8p7ezqisewxPBdVBbL7zdGTwPyL2xc3CjMj/INZIRXccOx5yuOhIkCTZ 8ecGtFdURm5e5+DTy1xztWLivryjcwntra7AuYmE/dJv/wscNKW3D0ngmf9cYtKNVT2/mM lYGoV/lOOOkShv5NLAhdmFKGupwVemU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-316-dqDaZNJnM8W1ME15UqP39g-1; Thu, 11 Jun 2020 17:38:11 -0400 X-MC-Unique: dqDaZNJnM8W1ME15UqP39g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46322835B42; Thu, 11 Jun 2020 21:38:09 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC650100238D; Thu, 11 Jun 2020 21:38:05 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, matan@mellanox.com, xiao.w.wang@intel.com, zhihong.wang@intel.com, xiaolong.ye@intel.com, chenbo.xia@intel.com, david.marchand@redhat.com, amorenoz@redhat.com, shreyansh.jain@nxp.com, viacheslavo@mellanox.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com Cc: Maxime Coquelin , stable@dpdk.org Date: Thu, 11 Jun 2020 23:37:36 +0200 Message-Id: <20200611213748.1967029-3-maxime.coquelin@redhat.com> In-Reply-To: <20200611213748.1967029-1-maxime.coquelin@redhat.com> References: <20200611213748.1967029-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 02/14] bus/fslmc: fix null pointer dereference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patches fixes a null pointer derefencing that happens when the device string passed to the iterator is NULL. This situation can happen when iterating on a class type. For example: RTE_DEV_FOREACH(dev, "class=eth", &dev_iter) { ... } Fixes: e67a61614d0b ("bus/fslmc: support device iteration") Cc: stable@dpdk.org Cc: shreyansh.jain@nxp.com Signed-off-by: Maxime Coquelin --- drivers/bus/fslmc/fslmc_bus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index afbd82e8db..75c15d6b67 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -603,6 +603,11 @@ fslmc_bus_dev_iterate(const void *start, const char *str, struct rte_dpaa2_device *dev; char *dup, *dev_name = NULL; + if (str == NULL) { + DPAA2_BUS_DEBUG("No device string\n"); + return NULL; + } + /* Expectation is that device would be name=device_name */ if (strncmp(str, "name=", 5) != 0) { DPAA2_BUS_DEBUG("Invalid device string (%s)\n", str);