Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp671863pxf; Wed, 24 Mar 2021 13:00:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv/iuzZ9lrUW3Ow2PYqpNO65EpwrW/cfsHzSygXujK4No8ZyUhCKw2tFdvYUspxWJjuJOg X-Received: by 2002:a17:906:a1c8:: with SMTP id bx8mr5489224ejb.381.1616616039558; Wed, 24 Mar 2021 13:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616616039; cv=none; d=google.com; s=arc-20160816; b=GtfksqtzdoPWO8zNtbqAUhsbNw7wuCxATSCQzEePNp9B5WjgFePRkFSqkI6MmaTPoT 1J39iU5kTZsg+5fMp30TUOKDAEON+8ONwI9T7rqWV6MUhtYFHujiBcxE07fHd0cs4iIf 6lv6qfj1STfAmF0p8y8GfOFJvWGkTdBq+BAU0q1M3dfWcllgRG416WDqAPpW8siCxnm7 GlhsKVrFHxc+KjIhhyJVHCZtMo6RkyEhj84XxqzmiexFUnffCPj0vaEvFOyGlJIN+oAN ncUNf04I4ne+Os8TMbqsB8ociBEQN+H9XyxQx6qGMsPPQWonYFrfieAY8Q91rq8T8Ikt 5caw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=6wje3u9/LXf+fY5O7zx9Tl/wzeXgMCXQSJ1thmeKKYE=; b=OUDN/yTAZ2lj6acwr0LE39sOrfvHoZPjJwjmSCqK2PXlcxLuEnSwBELZLdID14CQKh 36GI7zoFoFCMofz7AJOxMgIlwP7Pc1LtRxihQgRQuVZp6JshQIdsVN649zFgL5WZdMcc l/PiQCB+mUUyrWe4CNi3IrUwhL9Y4oE3L3cQ6nVfHSP2aDTEWdqGVzxAXpMkei4TBdcv 0xQlcSMlu6UXFKasy+07g8hVWGyclp+cGFrljZTO1yyk8PHPX04pBHqJQhzyb1MOrS2n 3g4BS+xnxt/VjBsUQSc9H7KUW9ArLpp4WdW0KUv/oAoPzyhhKA9vjlMwDXqsdacIVbEn EviA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UXnapM+u; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx20si2558384edb.215.2021.03.24.12.59.51; Wed, 24 Mar 2021 13:00:39 -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=UXnapM+u; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237911AbhCXT5t (ORCPT + 99 others); Wed, 24 Mar 2021 15:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238002AbhCXT5t (ORCPT ); Wed, 24 Mar 2021 15:57:49 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB2DC061763 for ; Wed, 24 Mar 2021 12:57:48 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id j25so18190578pfe.2 for ; Wed, 24 Mar 2021 12:57:48 -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=6wje3u9/LXf+fY5O7zx9Tl/wzeXgMCXQSJ1thmeKKYE=; b=UXnapM+uUzWVFHRiBlLLL1zWvGJKqjoZF2CvY3BY7ukyM1pwtw9wFyNYL/bugsIi5H 1fd+dM1XyXiniMl2xByDVLvLwUEALXjQ5RIr7lhx6bymj8e/i68g1k2Ojjg5e3/cVkai 92hByEyaYIfObfW/yEOAQGbVxV36E6HqKgePvZq17Ab1SIUFr6Smi/sL1/SoJXCAcntH sokHXuZrupuVmCjDHXWJEAXzh/HDPTNLpgo52MtaW8359nAJiuF4BFOvcF/4mqyZAGmH KJFaZt5VmGPDDDMQRkMykO2daw9YWHWayZ3J/YJXVwDY31VYa92jNpblNQIqkUj1Xnr3 wqJQ== 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=6wje3u9/LXf+fY5O7zx9Tl/wzeXgMCXQSJ1thmeKKYE=; b=UXsu2ZChiqDkGrkl+lq+GWMw+a32eCLYRMSrN1nd1iisqdYLCjV6sQDG7nZL2aNI+F 5q+PKRok8BQIVdLkhNHxThivYuSGE+OCEwzDii5UEiqcIDvaCyBwKipOrn7wlh0oYLyk lUsFAJD84Of0m9tJGZVHYjiyIJohdclhVoQG6iVRO8SKG2wD/HUUVrRsS5qNxgpmbnb9 0Iv9Ti7eWU5Q6VlW0p03WK3KkUWgEgofqPs32lIFKgu65SrQLk74jLPVV5SuKrxUhLAV zGHb53zsZVPv91vZcut1qQEzrcbDn4BXMzs43LnC3OyxpgGWO+l1Y4nb2gYxnB//Obwm Xg4A== X-Gm-Message-State: AOAM532dt0y4ecv0Mjio0Fly9E8GjxF+/GHLTmfd7oTzg3VTCRlyGy+X MDMoqEM6NvssN0FjULyDV7A= X-Received: by 2002:aa7:980a:0:b029:20c:5402:5de9 with SMTP id e10-20020aa7980a0000b029020c54025de9mr4708822pfl.18.1616615868433; Wed, 24 Mar 2021 12:57:48 -0700 (PDT) Received: from google.com ([2620:15c:211:201:7dfa:1e53:536:7976]) by smtp.gmail.com with ESMTPSA id e8sm3314971pgb.35.2021.03.24.12.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 12:57:47 -0700 (PDT) Sender: Minchan Kim Date: Wed, 24 Mar 2021 12:57:45 -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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <89ba4c7a-42d2-5412-2367-cc1cffc1117b@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 24, 2021 at 10:49:58PM +0300, Dmitry Osipenko wrote: > 24.03.2021 22:43, Dmitry Osipenko пишет: > > 24.03.2021 22:20, Minchan Kim пишет: > >> static int __init cma_sysfs_init(void) > >> { > >> - int i = 0; > >> + struct kobject *cma_kobj_root; > >> + struct cma_kobject *cma_kobj; > >> struct cma *cma; > >> + unsigned int i; > > > >> while (--i >= 0) { > > > > Do you realize that this doesn't work anymore? > > > >> cma = &cma_areas[i]; > >> - kobject_put(&cma->stat->kobj); > >> - } > >> > >> - kfree(cma_stats); > >> - kobject_put(cma_kobj); > >> + kobject_put(&cma->cma_kobj->kobj); > >> + kfree(cma->cma_kobj); > > > > Freeing a null pointer? > > > >> + cma->cma_kobj = NULL; > >> + } > >> + kobject_put(cma_kobj_root); > > > > Please try to simulate the errors and check that error path is working > properly in the next version. > > Alternatively, we could remove the cma_kobj_release entirely, like Greg > suggested previously, and then don't care about cleaning up at all. Does he suggested it to remove cma_kobj_release?(Initially, I did but was rejected from Greg)