From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 8E76F5F38 for ; Wed, 19 Sep 2018 18:28:20 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id t84-v6so2997202pgb.5 for ; Wed, 19 Sep 2018 09:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eHJbXZA2YvD39wBBiOZ5gyI/DdgnSY2sOAoh99qsiDM=; b=ukw5aNpcHlaUPROJTHys1Mkz4iBFh2iRqZe/VVaagd3Y9oTb7AvWqf2s1AT6EPomBq cc4OMVXDIeREinwfnHLEROs/HN/K9emio1mkpkrZA4EcBii+hos31H1svalbYmSjZHLM cTYfUNUoyxvZpb2UlFvL8A8CuYQriBajLmFIQQ40PWc266NNzQ2s0fL4IEWIgcYZssi1 pWfpzdQrzRvMb8JpTIQtoyg14re5RWLggunp87zzg3+KsuntUiDBf4sntRzvNMpg8rP2 sk2J3XRRc7TC1C0QQo6h+zXyyIsmdv7rGcdRtz50FB9OLwav+X19xguijmJkbXy4KDGB K28A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eHJbXZA2YvD39wBBiOZ5gyI/DdgnSY2sOAoh99qsiDM=; b=E2fGrabvFg6qYQ66QT4l1oLJ20lJsvxJ2XmzOuGmqU7FDOy7humGUgkszMNwv6wF9R ShFWkqLTGenwlfepMuocvWdRK+F4sEeqFuhzW1MLjZOvezSi6njAzlsTZ5dJ0R26XICu 5V0llHznyFJkFovE9vc/cjXe65/bRg3PIThirS6oC/FNRvG5db2SJQo5avALytwskgix coOZ+zieUUpZmDQ4YVLllqBg4MpJyRhsFIrxRFnZENU9YVB78P04T9f+gWXhqUHjzr17 2jO67ux5yb79TPps8jbohWw5vfiTxt0nOFgTvtv8sRHWVZdYvPIJ/2ZEmAe8DaRcQnut SIWw== X-Gm-Message-State: APzg51BB2kcsgT0tm66LhLo65+biOlDAPKOasLJ+lDtqV4TGdY2FAWdK 3OmB25rb3xvj+gWpzOF+SRzPCQ== X-Google-Smtp-Source: ANB0VdbuXGYxyBo8Y0MZ1Lzba7O9MJPcKHykRwlzTVzUEo8gs53ThsM2Sstz/hRP95drFTyxizMB4Q== X-Received: by 2002:a62:4dc1:: with SMTP id a184-v6mr36776269pfb.5.1537374499628; Wed, 19 Sep 2018 09:28:19 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id m25-v6sm26663751pgn.1.2018.09.19.09.28.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Sep 2018 09:28:19 -0700 (PDT) Date: Wed, 19 Sep 2018 09:28:09 -0700 From: Stephen Hemminger To: Andrzej Ostruszka Cc: dev@dpdk.org, mw@semihalf.com, zr@semihalf.com, tdu@semihalf.com, nadavh@marvell.com Message-ID: <20180919092809.7ccde128@xeon-e3> In-Reply-To: <1537369294-17099-2-git-send-email-amo@semihalf.com> References: <1535720386-18775-1-git-send-email-amo@semihalf.com> <1537369294-17099-1-git-send-email-amo@semihalf.com> <1537369294-17099-2-git-send-email-amo@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 1/8] net/mvneta: add neta PMD skeleton 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: , X-List-Received-Date: Wed, 19 Sep 2018 16:28:20 -0000 On Wed, 19 Sep 2018 17:01:27 +0200 Andrzej Ostruszka wrote: > +/** > + * Create private device structure. > + * > + * @param dev_name > + * Pointer to the port name passed in the initialization parameters. > + * > + * @return > + * Pointer to the newly allocated private device structure. > + */ > +static struct mvneta_priv * > +mvneta_priv_create(const char *dev_name) > +{ > + struct mvneta_priv *priv; > + > + priv = rte_zmalloc_socket(dev_name, sizeof(*priv), 0, rte_socket_id()); > + if (!priv) > + return NULL; > + > + return priv; > +} Why make this a function, it really doesn't add anything over just doing it inline. > +static int > +mvneta_eth_dev_create(struct rte_vdev_device *vdev, const char *name) > +{ > + int ret, fd = socket(AF_INET, SOCK_DGRAM, 0); > + struct rte_eth_dev *eth_dev; > + struct mvneta_priv *priv; > + struct ifreq req; > + > + eth_dev = rte_eth_dev_allocate(name); > + if (!eth_dev) > + return -ENOMEM; > + > + priv = mvneta_priv_create(name); > + > + if (!priv) { nit: no blank line needed. > + ret = -ENOMEM; > + goto out_free_dev; You have error goto's backwards. > + } > + > + eth_dev->data->mac_addrs = > + rte_zmalloc("mac_addrs", > + ETHER_ADDR_LEN * MVNETA_MAC_ADDRS_MAX, 0); > + if (!eth_dev->data->mac_addrs) { > + MVNETA_LOG(ERR, "Failed to allocate space for eth addrs"); > + ret = -ENOMEM; > + goto out_free_priv; > + } > + > + memset(&req, 0, sizeof(req)); > + strcpy(req.ifr_name, name); > +out_free_mac: > + rte_free(eth_dev->data->mac_addrs); > +out_free_dev: > + rte_eth_dev_release_port(eth_dev); > +out_free_priv: > + rte_free(priv); These are backwards: out_free_priv is called if ioctl fails and will leak eth_dev port. > + return ret; > +}