From patchwork Wed Jun 14 17:28:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 9787085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4C6B7602D9 for ; Wed, 14 Jun 2017 17:28:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31E7620242 for ; Wed, 14 Jun 2017 17:28:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 265AF2521E; Wed, 14 Jun 2017 17:28:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A43F205A8 for ; Wed, 14 Jun 2017 17:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751904AbdFNR2l (ORCPT ); Wed, 14 Jun 2017 13:28:41 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:35938 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751714AbdFNR2k (ORCPT ); Wed, 14 Jun 2017 13:28:40 -0400 Received: by mail-wr0-f174.google.com with SMTP id 36so9867338wry.3 for ; Wed, 14 Jun 2017 10:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cF5/m4oERuyw02gednn+K4YP9wsSccHRoyPciAiXxEI=; b=Ttgu1I40fXsah8QMqJSnuolMOPLdSOGRSLkkkq0pIv35TZH3x8e88bqs5doYhC82qy E3VteGkxelOTxJfJA5HEsdwc0kAFVyQbWxE0dsjJL+sOTloQpT2Z1GHoi3kp9G5gcAkV 8TsQ6krXyp7dzy0vaB6KUX98kqxDj88cJGJGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cF5/m4oERuyw02gednn+K4YP9wsSccHRoyPciAiXxEI=; b=lMMe79PKlpag8qkLg0xsEywtuyv5SOC9iIbUN9/T87lcrhL5xsADof1cRtJ3iZj7Za yKIF3cDDblqcjczM8qSjqbGSMMub9gcxBGHdMmSi9GVMt4ccg2IRouFIaYwXdcHDiBD3 b/SmjG2fDguuztAmhk1IoYX35kjzEy2mF/S0TGJrFsIBE8+Qk4isrpQdqCAOg/LgXb/K spoYzqoxDy9iX9Vhibd5Z5i8yoxYtfTU1s4fFGSKpInpy8z5oC1+5ARKfbT6X82SYJl+ UEGEFwehLf3mKJBT0xuYnZ7VYkj5gGLi93HvCD+50FbrBOWwnligzQeT9nmlMaP7k/ss ZzoA== X-Gm-Message-State: AKS2vOwupC5RHj+D8kBvGFJsep7NTeCWjI41WZcj9Z87oysEMLXeTD4Y cu5O9EW3d9qU/8FkO8fTVQ== X-Received: by 10.80.133.100 with SMTP id 91mr848430edr.19.1497461318968; Wed, 14 Jun 2017 10:28:38 -0700 (PDT) Received: from [192.168.178.39] (f140230.upc-f.chello.nl. [80.56.140.230]) by smtp.gmail.com with ESMTPSA id f22sm361009edf.59.2017.06.14.10.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 10:28:38 -0700 (PDT) Subject: Re: [PATCH] backport: handle change in netdevice destructor usage To: Johannes Berg Cc: backports@vger.kernel.org References: <1497258385-5116-1-git-send-email-arend.vanspriel@broadcom.com> <1497387587.6068.15.camel@sipsolutions.net> <5d265e01-bd12-801b-b604-ef7107e9373c@broadcom.com> <1497446815.9377.0.camel@sipsolutions.net> From: Arend van Spriel Message-ID: <079165f7-cccb-8712-7090-a9b9ed929dba@broadcom.com> Date: Wed, 14 Jun 2017 19:28:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <1497446815.9377.0.camel@sipsolutions.net> Content-Language: en-US Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 14-06-17 15:26, Johannes Berg wrote: > On Wed, 2017-06-14 at 15:25 +0200, Arend van Spriel wrote: >> On 13-06-17 22:59, Johannes Berg wrote: >>> On Mon, 2017-06-12 at 10:06 +0100, Arend van Spriel wrote: >>>> This patch deals with changes made in struct net_device by commit >>>> cf124db566e6 ("net: Fix inconsistent teardown and release of >>>> private >>>> netdev state."). This only looks for instances that need >>>> free_netdev() call, ie. struct net_device::needs_free_netdev == >>>> true. >>> >>> Come to think of it, isn't this missing the part where we now call >>> priv_destructor when registering fails or something? >> >> Ah. I should have studied the patch better to see what behavioral >> changes the commit imposed. > > Not sure, tbh. I just think there are issues there. > >> So are you still considering the patch >> despite the likely backport of commit cf124db566e6. I can do my >> homework better and resubmit if needed. > > Yeah I still think this backports patch makes sense, since I'm not sure > I want to fix mac80211 that way (the bits in unregistering multiple > netdevs are awkward) and brcmfmac would still need it. So I changed the semantic patch as below, which fixes the error path when register_netdevice() fails: @@ -1884,6 +1889,7 @@ int ieee80211_if_add(struct ieee80211_lo ret = register_netdevice(ndev); if (ret) { + ieee80211_if_free(ndev); free_netdev(ndev); return ret; } Unfortunately, it also creates the following hunk: @@ -1779,6 +1783,7 @@ int ieee80211_if_add(struct ieee80211_lo ndev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); if (!ndev->tstats) { + ieee80211_if_free(ndev); free_netdev(ndev); return -ENOMEM; } All ieee80211_if_free() does is freeing the tstats and it deals with null pointers. So for mac80211 this is ok but not generically. Not sure how to tackle this in a semantic patch. Regards, Arend --- -- To unsubscribe from this list: send the line "unsubscribe backports" in diff --git a/patches/0079-netdev-destructor.cocci b/patches/0079-netdev-destructor.cocci index d8a439d..71b5525 100644 --- a/patches/0079-netdev-destructor.cocci +++ b/patches/0079-netdev-destructor.cocci @@ -14,6 +14,15 @@ C(...) @r2 depends on r1@ struct net_device *NDEV; identifier r1.D; +@@ + +- free_netdev(NDEV); ++ D(NDEV); ++ free_netdev(NDEV); + +@r3 depends on r2@ +struct net_device *NDEV; +identifier r1.D; identifier r1.C; fresh identifier E2 = "__" ## D; @@