From patchwork Tue Jun 23 08:12:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1314984 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=QJf3EcEu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=V2nDFFw6; 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 49rfGj5jSQz9sRf for ; Tue, 23 Jun 2020 18:15:21 +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=gBecVBPKU4ISYKlU4uN2xlVqSQGgUE53wWFtF5Y/Syk=; b=QJf3EcEu9r4gcQCBBTiPY5DRrO SF5YvEh9o50n98SswRGo3pQ3T9VN6tY3yXzLZ2cHY8sDbSpBBKLhQBzz7hEeZ0YhZGflbUxZ9HGxS Qm0N2BheUiOPFviKtLv0BDa01TIrQ7iPXP1/PxqooQA74lf2prVn2b+/3D7Ruinm9Q3JbvW6Jf2gW Rm3l+cO2qbvJCw6sEv+nkng60DKbe6ycO1bLT1bi7HQKJwQlnoFUFQ8YwPUDU+vtIKqOEImiPdzoo SQQt42hD0o8mIgZdGftgwYdMZ015NbQBsCI+eXasseyfTHn5x2zFp2J5Yyo04YS58zc+2bB5bmzqH l20MjUSA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jne2q-00057H-PU; Tue, 23 Jun 2020 08:12:40 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jne2o-00056l-1k for openwrt-devel@merlin.infradead.org; Tue, 23 Jun 2020 08:12:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=JILHEoEEL3kpmcmbI3gNTKPW44YZQcFmetOJ8xQ877A=; b=V2nDFFw6Gw/TDcRU+wTqgll9JR A7Yk+gwJmucjCj5+hx/Mkdn8l4+LDsvXHHdZV7W2yjtU6nfbQOAfKMyStKIxjjRHydo4kTlBRUsss fFhkAtPBn2pxtEKPHoz1wcm26elccVayl8GHkBiMRkaVWFwEanz5/k4DCjIXxF6RoKd29PVyOH4EZ Y4TW56nB5r+VqyZRL0576RvdMQrqhtyHGsjUHW2oXVz3meWsdkOhm1M+kR6xTNgo7zk2gwl4FuSPH kAdv8YYiWvxoIFBocEfn30NJqnMaURvSWyvRinZerTXUdV1MylKUea5xT0Y4ipRLSA61zAnXZ/rjS BeJIUNQg==; Received: from nbd.name ([2a01:4f8:221:3d45::2]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jne2k-0007wp-7X for openwrt-devel@lists.openwrt.org; Tue, 23 Jun 2020 08:12:37 +0000 Received: from [81.25.167.29] (helo=localhost.localdomain) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1jne2f-00026E-3q; Tue, 23 Jun 2020 10:12:29 +0200 From: John Crispin To: openwrt-devel@lists.openwrt.org Subject: [PATCH] netifd: fix wdev->data lifetime Date: Tue, 23 Jun 2020 10:12:17 +0200 Message-Id: <20200623081217.863743-1-john@phrozen.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200623_091234_418117_BFC6E534 X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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 --- wireless.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wireless.c b/wireless.c index efb7992..0aad8c7 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); @@ -1415,6 +1414,8 @@ wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data, return UBUS_STATUS_INVALID_ARGUMENT; *pdata = blob_memdup(cur); + if (*pdata) + free(*pdata); if (vif) wireless_interface_set_data(vif); else if (vlan)