From patchwork Tue Jun 23 09:40:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1315036 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=phrozen.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=xwS4fDvd; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49rhDH08dSz9sRR for ; Tue, 23 Jun 2020 19:43:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Y0aepI3FxcyuCxoolzylCzLc7hOT39e1D9VwB9XSa5c=; b=xwS4fDvdAgV1GkAkx/ed9IRHGW aTQduFXSu6cE/rHO/N1D3Cc59rMgwi85lfclYtZ0MBHzfMtvDcvunswldEE1vT44Uev1N1eK4qJDk WJt9pPrpvqsSZUUcXr1NrtnoEVXG3FzlFHXi1u4TEjcnJrWggiMVeGKT0lSVMUEY8n9ugCxwdjP7V mLz8129jYAK34c8LUrCuzsX2py7nsgWC4O4TP2WGH5TntOKVJOSrfsTf7052lCY+k52ZGSCpsiwsn 77MbCcayysU1luuIWkdrJTzpXNkYF2QOcCAX3Oz8NVnjIM+By9jbYosKKRPbK/xKgKNQNzqIk5T78 TjoORdcw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnfQ0-0000Yf-MR; Tue, 23 Jun 2020 09:40:40 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnfPv-0000WH-SK for openwrt-devel@lists.openwrt.org; Tue, 23 Jun 2020 09:40:37 +0000 Received: from [81.25.167.29] (helo=bertha9.lan) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1jnfPt-00073F-0G; Tue, 23 Jun 2020 11:40:33 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Subject: [PATCH V1] netifd: fix wdev->data lifetime Date: Tue, 23 Jun 2020 11:40:28 +0200 Message-Id: <20200623094028.1248246-1-john@phrozen.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Crispin Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The reconf patch breaks wifi down under certain conditions. The root cause is that during reload the wdev state gets flushed. This has the effect, that the phy is lost from the state resulting in teardown breaking. Fix this by changing the lifetime of wdev->data. Signed-off-by: John Crispin --- Changes in V2 * free() call was in the wrong place wireless.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wireless.c b/wireless.c index efb7992..e295f28 100644 --- a/wireless.c +++ b/wireless.c @@ -275,8 +275,6 @@ wireless_device_free_state(struct wireless_device *wdev) uloop_timeout_cancel(&wdev->script_check); uloop_timeout_cancel(&wdev->timeout); wireless_complete_kill_request(wdev); - free(wdev->data); - wdev->data = NULL; vlist_for_each_element(&wdev->interfaces, vif, node) { free(vif->data); vif->data = NULL; @@ -460,6 +458,7 @@ wireless_device_free(struct wireless_device *wdev) vlist_flush_all(&wdev->vlans); vlist_flush_all(&wdev->stations); avl_delete(&wireless_devices.avl, &wdev->node.avl); + free(wdev->data); free(wdev->config); free(wdev->prev_config); free(wdev); @@ -1414,6 +1413,8 @@ wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data, if (*pdata) return UBUS_STATUS_INVALID_ARGUMENT; + if (*pdata) + free(*pdata); *pdata = blob_memdup(cur); if (vif) wireless_interface_set_data(vif);