Message ID | 1446108903-14412-4-git-send-email-david.marchand@6wind.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 65F8A8E91; Thu, 29 Oct 2015 09:55:15 +0100 (CET) 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 <dev@dpdk.org>; Thu, 29 Oct 2015 09:55:13 +0100 (CET) Received: by wicfv8 with SMTP id fv8so36189349wic.0 for <dev@dpdk.org>; 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 <david.marchand@6wind.com> 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 <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
David Marchand
Oct. 29, 2015, 8:55 a.m. UTC
From: Maxime Leroy <maxime.leroy@6wind.com> 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 <maxime.leroy@6wind.com> Signed-off-by: David Marchand <david.marchand@6wind.com> --- lib/librte_ether/rte_ethdev.c | 3 +++ 1 file changed, 3 insertions(+)
Comments
2015-10-29 09:55, David Marchand: > From: Maxime Leroy <maxime.leroy@6wind.com> > > 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 <maxime.leroy@6wind.com> > Signed-off-by: David Marchand <david.marchand@6wind.com> It is not clear what the problem is. And the driver fields should probably be removed or changed as it too tigthly related to the PCI driver.
On Tue, Nov 3, 2015 at 12:10 PM, Thomas Monjalon <thomas.monjalon@6wind.com> wrote: > 2015-10-29 09:55, David Marchand: > > From: Maxime Leroy <maxime.leroy@6wind.com> > > > > 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 <maxime.leroy@6wind.com> > > Signed-off-by: David Marchand <david.marchand@6wind.com> > > It is not clear what the problem is. > And the driver fields should probably be removed or changed as it too > tigthly > related to the PCI driver. > It does look odd to me as well, quickly went through head, and did not see a case where this could happen. Maxime is not available at the moment, so I think I will just drop this patch. How about this patchset rebased on head with just the first two patches ?
2015-11-03 12:19, David Marchand: > On Tue, Nov 3, 2015 at 12:10 PM, Thomas Monjalon <thomas.monjalon@6wind.com> > wrote: > > > 2015-10-29 09:55, David Marchand: > > > From: Maxime Leroy <maxime.leroy@6wind.com> > > > > > > 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 <maxime.leroy@6wind.com> > > > Signed-off-by: David Marchand <david.marchand@6wind.com> > > > > It is not clear what the problem is. > > And the driver fields should probably be removed or changed as it too > > tigthly > > related to the PCI driver. > > > > It does look odd to me as well, quickly went through head, and did not see > a case where this could happen. > Maxime is not available at the moment, so I think I will just drop this > patch. > > How about this patchset rebased on head with just the first two patches ? Perfect, thanks
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; }