From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BA8CC433DB for ; Wed, 24 Mar 2021 20:55:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3FE961A17 for ; Wed, 24 Mar 2021 20:55:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3FE961A17 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7AC216B031C; Wed, 24 Mar 2021 16:55:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 748D36B031D; Wed, 24 Mar 2021 16:55:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 610D06B031E; Wed, 24 Mar 2021 16:55:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 483C56B031C for ; Wed, 24 Mar 2021 16:55:54 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0C4303659 for ; Wed, 24 Mar 2021 20:55:54 +0000 (UTC) X-FDA: 77955974628.28.6E07829 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf23.hostedemail.com (Postfix) with ESMTP id 1CCC1A00038F for ; Wed, 24 Mar 2021 20:55:52 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id c17so11453003pfn.6 for ; Wed, 24 Mar 2021 13:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=bW7WoQMagjQIIn/8KR5VslHMG/0qRAE/ZaFZOdCtxDU=; b=CsGZg8KXX0+gDzDoUnbX6Y1biImPWLzCl2DUcsiu5txYHCEtbXGxarA02F0xZrd7Bl yX6HMNsYm2EIwXiBJ8qrS4IjBf3OngUaduS3sd6eZyfkUKcfPv+Bd7HyMDbw6LAMVLON 8XkT0BgYZyKDT4YRJ2FIoK/koDunktRmgKUddd2S7BzSSExQP0ay375xoQ/VgRN+yMg6 cb+RUNgyzswUsHxKPdPWMuPOPtMq2Jw7kbmZQrmOvPKoyPG3LPPIOGCnycaj37bNbc4h XeXZ+6SW0dj3y547kj/LCHPrd+nLguFMXCA8wdPi5qvdj1SAWP3bNavnpdfhze2WOcLZ Zn4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=bW7WoQMagjQIIn/8KR5VslHMG/0qRAE/ZaFZOdCtxDU=; b=Mchr8x3s5qv/Lgp5D7EO9syjs3Xn5SEm5+j8DfooCAeUI4/wUx1iJTMQpPCCbehOPe tuHd6RfS1/o6vKcBV4KsW/uM1Hd1SlV6ng1s4NX86ADBc2wjxGPfiXe2u8N7UnWU2I86 xEAsg+haOVSdKBWRuVZvKmzoiLN1p33OPxqBXxRZI577LFGZCtfeS2hea+xnesjdLOsv SfYpF9jmrSxjmccmdHZDbBhvV3weQBntyDrS11iqL5jhEE9XgNxndvP2oN4f3E5ymLj0 XSs1GRCYfvTNF/UasqRaqsy8YLn7/+jr88MxinOZm+MvSwla0zrgkDwefGf9wS59FaPG h3dw== X-Gm-Message-State: AOAM530ead/GDj4Twssb5HFpwzOlan7D1Pq22FuhZ6ygfhPXz708NZ0u z4yOf197wokd6oG1vnxG5Cw= X-Google-Smtp-Source: ABdhPJxWLuQACGwGD50bc0v5NiwE3SaRIWPHb0xTmcajBsHfu2DcB7sGbt2Y/fscZvWtPDnwMWWZYw== X-Received: by 2002:a62:2a07:0:b029:214:fd95:7f7 with SMTP id q7-20020a622a070000b0290214fd9507f7mr4891951pfq.60.1616619352778; Wed, 24 Mar 2021 13:55:52 -0700 (PDT) Received: from google.com ([2620:15c:211:201:7dfa:1e53:536:7976]) by smtp.gmail.com with ESMTPSA id v126sm3472399pfv.163.2021.03.24.13.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 13:55:51 -0700 (PDT) Date: Wed, 24 Mar 2021 13:55:49 -0700 From: Minchan Kim To: Dmitry Osipenko Cc: Andrew Morton , linux-mm , LKML , gregkh@linuxfoundation.org, surenb@google.com, joaodias@google.com, jhubbard@nvidia.com, willy@infradead.org Subject: Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count Message-ID: References: <20210324192044.1505747-1-minchan@kernel.org> <18ee5c3e-fba2-0d8d-bd93-5fb8d0dd7a01@gmail.com> <89ba4c7a-42d2-5412-2367-cc1cffc1117b@gmail.com> <900f5707-3352-e3d1-69e8-c1f8580c0fc4@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <900f5707-3352-e3d1-69e8-c1f8580c0fc4@gmail.com> X-Stat-Signature: 7o6bzxqkk7ea7jw9df399wu9pjd43kub X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1CCC1A00038F Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf23; identity=mailfrom; envelope-from=""; helo=mail-pf1-f169.google.com; client-ip=209.85.210.169 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616619352-377107 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Mar 24, 2021 at 11:02:47PM +0300, Dmitry Osipenko wrote: > 24.03.2021 22:57, Minchan Kim =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > On Wed, Mar 24, 2021 at 10:49:58PM +0300, Dmitry Osipenko wrote: > >> 24.03.2021 22:43, Dmitry Osipenko =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > >>> 24.03.2021 22:20, Minchan Kim =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > >>>> static int __init cma_sysfs_init(void) > >>>> { > >>>> - int i =3D 0; > >>>> + struct kobject *cma_kobj_root; > >>>> + struct cma_kobject *cma_kobj; > >>>> struct cma *cma; > >>>> + unsigned int i; > >>> > >>>> while (--i >=3D 0) { > >>> > >>> Do you realize that this doesn't work anymore? > >>> > >>>> cma =3D &cma_areas[i]; > >>>> - kobject_put(&cma->stat->kobj); > >>>> - } > >>>> =20 > >>>> - kfree(cma_stats); > >>>> - kobject_put(cma_kobj); > >>>> + kobject_put(&cma->cma_kobj->kobj); > >>>> + kfree(cma->cma_kobj); > >>> > >>> Freeing a null pointer? > >>> > >>>> + cma->cma_kobj =3D NULL; > >>>> + } > >>>> + kobject_put(cma_kobj_root); > >>> > >> > >> Please try to simulate the errors and check that error path is worki= ng > >> properly in the next version. > >> > >> Alternatively, we could remove the cma_kobj_release entirely, like G= reg > >> suggested previously, and then don't care about cleaning up at all. > >=20 > > Does he suggested it to remove cma_kobj_release?(Initially, I did but > > was rejected from Greg) > >=20 >=20 > Alright, I haven't followed the previous threads fully and only saw the > reply where he suggested to removed it. No problem. I just posted it new version. Hopefully, it tastes good for you. ;-) Thanks for the review!