From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by dpdk.org (Postfix) with ESMTP id 4E83C8E76 for ; Thu, 29 Oct 2015 09:55:13 +0100 (CET) Received: by wicfv8 with SMTP id fv8so36189349wic.0 for ; Thu, 29 Oct 2015 01:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IvVmLJHq3ncalzM09gSy5aTCw36D/NKeVhGqamCSx6g=; b=ItEOu2VihpaCDHvtkbm18arA4Ady6UIWabwFm2ksd4MgUa5s43metBhmijnj82UKA9 pdWEmR8ki6VYN2qDMEauyTFuQUSp5QtoeAeyZfxcVSwA97899FDPLn81uAQYDrdgomvE tcvTPeCYm0LrPTHEXaiu9YmGRfEiZDPLqPkK0IS8MV8XwBlJNN9zbJ48cCz9Wosw2XOe XEr9xVvJgJQNJWIrVHjKURg2oeeNjdLniIyJPHTCz9+mPmawg10FRbqaEfjrFfr8Ak2e LWAdrwMag0xBtViVtgKdB/LeI5zUXI+a/XQmZ898ReZx+BsXB0vWFjOPD2SHTXXryx9f g6EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IvVmLJHq3ncalzM09gSy5aTCw36D/NKeVhGqamCSx6g=; b=WETdRB3ahHKPCOIA1uuRJX877QuucU7YuQmd1UuTgCQggGtb52vJgpUt4DCWZAY/fR ps32jEjS/O7+gbdsvvlvI1YRpusgRl4eeKh3T9y7fZiB9Gb9RtKC1h2U6wBV3QH0rOfH jL9rHJW/MjdW3h4ZRAoY05De2dbU85uTr1LS6TAeZNpt2GwbVm4LXRj+ytJdZg178EsT kyHhOL9QgVMOCcj2rkr6tJrOohz2V69waRhwhfv/sSaPzWlW7HfXLmQ7I4zWseIzwfwv BybZj8oNDUdX3kIlNNsqOpLo5xFq3ELc8LB1D9RjtUkLgd1xfzkU7VrXPkdEjCT9xd5z uB1A== X-Gm-Message-State: ALoCoQmxwXE2fG7FYm2nca1m/aoT6oc1/nakQ4EazhR41FIK73GPd2y++O8xiG0N50VEo5EN3Sgt X-Received: by 10.194.57.142 with SMTP id i14mr852918wjq.24.1446108913065; Thu, 29 Oct 2015 01:55:13 -0700 (PDT) Received: from gloops.dev.6wind.com (89-158-215-180.rev.numericable.fr. [89.158.215.180]) by smtp.gmail.com with ESMTPSA id xt1sm624273wjb.32.2015.10.29.01.55.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 01:55:12 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Thu, 29 Oct 2015 09:55:03 +0100 Message-Id: <1446108903-14412-4-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446108903-14412-1-git-send-email-david.marchand@6wind.com> References: <1446108903-14412-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH 3/3] ethdev: prevent segfaults in rte_eth_dev_is_detachable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2015 08:55:13 -0000 From: Maxime Leroy Some drivers like virtual ones don't specify any driver pointer in the structure rte_eth_dev. To prevent segfault, we should check if this pointer is NULL before dereferencing it. Signed-off-by: Maxime Leroy Signed-off-by: David Marchand --- lib/librte_ether/rte_ethdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 7fa5717..750e4b5 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -522,6 +522,9 @@ rte_eth_dev_is_detachable(uint8_t port_id) } } + if (rte_eth_devices[port_id].driver == NULL) + return 0; + drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags; return drv_flags & RTE_PCI_DRV_DETACHABLE; } -- 1.9.1