Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1218086pxv; Fri, 23 Jul 2021 03:01:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKZY6DE1fc3Gl4lm72T3CFU5hmyQTddFBMRtqjhX2MFT7DJp0qXvuYHEtMZViunA8xbUnW X-Received: by 2002:a5d:840c:: with SMTP id i12mr3300656ion.185.1627034484857; Fri, 23 Jul 2021 03:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627034484; cv=none; d=google.com; s=arc-20160816; b=SZ8k2TVjMg5giYWM83fFUJ2yABEiUcQPQOZafb+KrXRR6j+LFkWJX4Lek06uEG6P4w k5OR8wjmKyoPtwJ5VxemNCbijsdWqr0ZFcQI4VLa81PhxGKOw6IRB/Kk6eFEMHnM8AiC Lndopx/AlfyCXHz14vJtbbWg7Lm4/9NjahMUnmhpou16ZKR3wpD16LgusaaCs5+kfbCP U6hbYaFq042fpdfaeHQiUXmV1ixAiPrw+rSC0it72ezq/CsiOO1ngvtsT7WNABnK+M7w QCmOrPW+NWYHxDekRP8PL92XVRv1XZVvUb1Rg3DA3OfikJ0Ol4mnkj0Sp7si9k/hDHMd ziwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZpV/vhONNALORyd7/Lzj0LakU5S+Xd5zMk4SZvs6RU4=; b=bZj19pzAEKBTd8we2GSKTv+g9czHfp8+FCBWhYzrc5AtBm0l4YrCdse9fKgB50qJwv EUbB5WezEz1yoSL9MKt/E3G7CTY2tC5oDsQeOunCvCRjANXZuqQtqzyHfRHsiQ617wmR LnInalzbO+2RbwG65EmcxanOB1M8dBUzu/fDkZk1rJs7ZboiQEXYJ6rW5qsJ7+Sn9ce5 hc9Y/JsOdc9GYVqumdcItgOFJ//cjwJ4HpeUMU9NZxDHMqYFtTVYIgKnf/tO/VNZM3jM wkHOiJTJyN2T10Xq6VlKhc/tJX8tslrDlLhcDVQEDHdq5scuxvquCeWwJzQyzBz5VtRY khXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=C3gTWjAI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t11si35571994ilu.68.2021.07.23.03.01.12; Fri, 23 Jul 2021 03:01:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=C3gTWjAI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231679AbhGWJTh (ORCPT + 99 others); Fri, 23 Jul 2021 05:19:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbhGWJTe (ORCPT ); Fri, 23 Jul 2021 05:19:34 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A0F5C061575; Fri, 23 Jul 2021 03:00:07 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id m24so997460edp.12; Fri, 23 Jul 2021 03:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZpV/vhONNALORyd7/Lzj0LakU5S+Xd5zMk4SZvs6RU4=; b=C3gTWjAIVXsJ4l7MrNGFHWpm+9NAtWTyOYv1gLDC2Is/bpbyYO31SXCbabv0iIItbv DWS6UpYh+hAYbrO+H2hp/7BxPtBtjX3CVJpBGNuBZsjNbZDlpOGoM1NEcjv0I6nlFUIk hh+eUrgUM+y6uEeLV9/Cwqv/TtZoqxrCD7KzzyAk7d5I31yGpkjPWAf0CSFBEBd5izHo gqr4dLVkDNskq6a40gGnSOVpvOcaM9zuCHvkQ7cYX0el5EL2tpYJlTSvBWnn5vTC3h4n kM+aVZJ6Qdf+j9TGk2iccKz5VWt4nbUbFLnqr3B1WxvHLrC3mv1VkCq3RlCf10ggCJb3 IF5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZpV/vhONNALORyd7/Lzj0LakU5S+Xd5zMk4SZvs6RU4=; b=XNotwsh2TjhnPw5pRs4OlCRc7U74c4SjArTLH9FdJrWlLcIU1LZhaCcFNBjuAMLbTv 26PBbKCp9AtKREWeEK6CYIA9sDbpfm37pIggZFmwFvA8CshITCofgHkF6Iv2VxEOuZj0 NvdfFurVNfKMOxWXi1tFIwx/AbyIS8tSTNlSfLHJowLoV5pStOPCKLC5gzZGPsnTQWzc umqvHs/ucQaCd7I5s4zzYedxys47frb/f7MuV2EXaSSIcLUo6YABtxCD3VuL2abf7wSv FVzI6wXk4aOjIWgnGdD0mSYJ8GuZuCaN558VDbXfECUGAMIAWGnj0H53pOwdNOOuu2oQ Z6xw== X-Gm-Message-State: AOAM533b5vojx+TCba3NTi6+qVp1z/2bWWSXMdrS0dvhbd2C1Ud/yh+Q oNowZEdGlbyr2KHzcpd3acy0/wne9TX0m7b1MdU= X-Received: by 2002:a05:6402:2228:: with SMTP id cr8mr4644804edb.309.1627034405768; Fri, 23 Jul 2021 03:00:05 -0700 (PDT) MIME-Version: 1.0 References: <20210723050919.1910964-1-mudongliangabcd@gmail.com> <11ba299b812212a07fe3631b7be0e8b8fd5fb569.camel@sipsolutions.net> In-Reply-To: From: Dongliang Mu Date: Fri, 23 Jul 2021 17:59:39 +0800 Message-ID: Subject: Re: [PATCH] cfg80211: free the object allocated in wiphy_apply_custom_regulatory To: Johannes Berg Cc: Kalle Valo , "David S. Miller" , Jakub Kicinski , Luca Coelho , Ilan Peer , syzbot+1638e7c770eef6b6c0d0@syzkaller.appspotmail.com, linux-wireless@vger.kernel.org, "open list:NETWORKING [GENERAL]" , linux-kernel , Dan Carpenter Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 5:42 PM Johannes Berg wrote: > > Hi, > > On Fri, 2021-07-23 at 17:30 +0800, Dongliang Mu wrote: > > if zhao in the thread is right, we don't need to add this free > > operation to wiphy_free(). > > Actually, no, that statement is not true. > > All that zhao claimed was that the free happens correctly during > unregister (or later), and that is indeed true, since it happens from > > ieee80211_unregister_hw() > -> wiphy_unregister() > -> wiphy_regulatory_deregister() > Thanks for your explanation. Now the situation is more clear. > > However, syzbot of course is also correct. Abstracting a bit and > ignoring mac80211, the problem is that here we assign it before > wiphy_register(), then wiphy_register() doesn't get called or fails, and > therefore we don't call wiphy_unregister(), only wiphy_free(). Yes, you're right. In this case, wiphy_register is not called. We should not call wiphy_unregister() to clean up anything. > > Hence the leak. > > But you can also easily see from that description that it's not related > to hwsim - we should add a secondary round of cleanups in wiphy_free() > or even move the call to wiphy_regulatory_deregister() into > wiphy_free(), we need to look what else this does to see if we can move > it or not. I agree to move the cleanup operation of regd to wiphy_free API. That's the partial functionability of this function. > > johannes >