From patchwork Mon Apr 20 10:17:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 47337 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0FBB620553 for ; Mon, 20 Apr 2015 10:17:59 +0000 (UTC) Received: by wgiv13 with SMTP id v13sf36350331wgi.3 for ; Mon, 20 Apr 2015 03:17:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=2zQ3jrfWQ9uw7DpXwDIWQJgSfNZLHVVOaXe/CLcCU+g=; b=iXqhLJ8vvTpjBAQLhC2y+2HK7TUZebUQLoNpGRyC9RaLCJ4XMpTpRXM+xCWVPXRzb9 HsE52QJZMsKEA14yGDKQs4ESfgthSENP5QmHNQB3Tky9eG/nvdiABV9MRjj5dw6wCx8H 90axEC4L0wZA9WdwNszUO3zLQbMNzjphKQXECJKcCe4G0dPpe6d5rYBdSJziNh+qThFX YsW4aMsmD3xpitVbMOOf/HeSSy94X2fVVfxLeG5fu+3J8caF7I7dkxDhqZsx+sJcIj8u 91jXSIoNUIr3Zo6cNvkwReXPGGWwsmjIpexckyOALbW0upcr21eTEN2RI2/99xPx8+9K XReA== X-Gm-Message-State: ALoCoQk7YvzbjOveu1EpKjQWpIufMBVOCwIJAWzfq5eWM2AA8r2BEzxNs/Jt7YpXOlrtSUt1XKHs X-Received: by 10.152.206.36 with SMTP id ll4mr6876691lac.6.1429525078351; Mon, 20 Apr 2015 03:17:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.129 with SMTP id m1ls716569laf.76.gmail; Mon, 20 Apr 2015 03:17:58 -0700 (PDT) X-Received: by 10.152.7.209 with SMTP id l17mr15161921laa.100.1429525078208; Mon, 20 Apr 2015 03:17:58 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id xd3si14645171lbb.166.2015.04.20.03.17.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 03:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbuc2 with SMTP id uc2so126705389lbb.2 for ; Mon, 20 Apr 2015 03:17:57 -0700 (PDT) X-Received: by 10.152.5.72 with SMTP id q8mr14842133laq.73.1429525077913; Mon, 20 Apr 2015 03:17:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1342746lbt; Mon, 20 Apr 2015 03:17:57 -0700 (PDT) X-Received: by 10.55.52.4 with SMTP id b4mr26687587qka.37.1429525076571; Mon, 20 Apr 2015 03:17:56 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id o7si19089036qhb.69.2015.04.20.03.17.55; Mon, 20 Apr 2015 03:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id B4C4761CCB; Mon, 20 Apr 2015 10:17:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id B941061CC4; Mon, 20 Apr 2015 10:17:40 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1E06861CCD; Mon, 20 Apr 2015 10:17:36 +0000 (UTC) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com [209.85.217.170]) by lists.linaro.org (Postfix) with ESMTPS id 4C6DD61CC4 for ; Mon, 20 Apr 2015 10:17:35 +0000 (UTC) Received: by lbbuc2 with SMTP id uc2so126698387lbb.2 for ; Mon, 20 Apr 2015 03:17:33 -0700 (PDT) X-Received: by 10.112.142.232 with SMTP id rz8mr14472659lbb.74.1429525053439; Mon, 20 Apr 2015 03:17:33 -0700 (PDT) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id ew6sm3463978lbc.40.2015.04.20.03.17.32 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Apr 2015 03:17:32 -0700 (PDT) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Mon, 20 Apr 2015 13:17:14 +0300 Message-Id: <1429525035-21377-2-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1429525035-21377-1-git-send-email-ciprian.barbu@linaro.org> References: <1429525035-21377-1-git-send-email-ciprian.barbu@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH NETMAP 1/2] linux-netmap: fix device control sockfd leakage X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ciprian.barbu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The get_mac_addr function created a socket that was never freed. The device control socket should have been used instead Signed-off-by: Ciprian Barbu --- platform/linux-netmap/odp_packet_netmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/linux-netmap/odp_packet_netmap.c b/platform/linux-netmap/odp_packet_netmap.c index a4236cf..2988b96 100644 --- a/platform/linux-netmap/odp_packet_netmap.c +++ b/platform/linux-netmap/odp_packet_netmap.c @@ -87,8 +87,13 @@ struct dispatch_args { int odp_netmap_init_global(void) { + int i; odp_spinlock_init(&nm_global_lock); memset(netmap_devs, 0, sizeof(netmap_devs)); + + for (i = 0; i < MAX_DEVS; i++) + netmap_devs[i].sockfd = -1; + return 0; } @@ -148,9 +153,9 @@ static int get_mac_addr(pkt_netmap_t *pkt_nm) int sockfd; int err; - sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + sockfd = pkt_nm->nm_dev->sockfd; if (sockfd == -1) { - ODP_ERR("socket(): %s\n", strerror(errno)); + ODP_ERR("Error: invalid device control socket\n"); goto error; }