Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1168129pxx; Fri, 30 Oct 2020 04:00:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymLaPVwE6OfkSZILwIPt3pU1wWKjphBXOmcchJHsuHSCXh+w+j9fu8eRKn+JVhe1+a/qJ8 X-Received: by 2002:a17:906:2a41:: with SMTP id k1mr1745273eje.33.1604055607867; Fri, 30 Oct 2020 04:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604055607; cv=none; d=google.com; s=arc-20160816; b=M7OgoNrEz84DOaOHqpzbzVDQ7wuJMSpbwoeFxEN8UOC0uudzofpZQQNKzCkNlsYs+A ogFCQrBFNdLcVVEU1G2VAbR4f448295QycXddp0W25xTnHim02aGDEjpweC+nygQmGpw zR4ubzc27BwvawVHb1uJTqIRkSgHlWmcddJa09Ax+011doY5g9oMf6fZDXxgOm9V/RDB 6l+QftfysFlvY5i8YPL3g2ICzcDWZxtzwF6SHK1QjoQoHt3klZ6uiWua4rOZno/DLxrV qDO6E+mkYx14T1+0Xyx4aV507q2pKfnb89TR1XNmkde5qlE1g+CHvdzU42YM9xIg9TD8 YLSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=SO6oEyTkZxl1hDztjvSCsneqayiQsOdT8/gtvJfVVLs=; b=o+eZaiCJH3KRwJDczmpfWlRTJ0QA8n7LsjiBQzD1iMdiNSMieA8nXz7Ts89wenmf9Q gN5389ws3zleEJUFM7Vyjd6NX1gOoeoKzFXzHByJEcvPUZFXSI7qb5NegwiS+APS0jjJ OJAUNYA05tjWWz9PIa3xB1QvMiALSuX3omcncQ4OVCPPhkgfvbApu+okpAV+ZdG7y8sW MzkDatq94cQKggyvLF0hLkPebt2A7tCf4zsFPv1lB6u5Zs6IWhXA/jow/tD/BcyOD3x3 IBsJDYH6tx1uKuPvLctKkx5knzKSAjzYLWNSJ+fOc1z3pnP97Yl1ym+UwTTFwB92Cef1 SgVQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si4069976edr.422.2020.10.30.03.59.45; Fri, 30 Oct 2020 04:00:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726355AbgJ3K4H (ORCPT + 99 others); Fri, 30 Oct 2020 06:56:07 -0400 Received: from mga17.intel.com ([192.55.52.151]:15924 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbgJ3K4G (ORCPT ); Fri, 30 Oct 2020 06:56:06 -0400 IronPort-SDR: LwHVUYN1C0iCbJfqPRGJxmbUQcrIpY8EZIDyKDlz5UEQ5/UAMhNzOttAfjEOwz7X3Qy2bxet8n hNJ5B5FOjhAA== X-IronPort-AV: E=McAfee;i="6000,8403,9789"; a="148445230" X-IronPort-AV: E=Sophos;i="5.77,432,1596524400"; d="scan'208";a="148445230" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 03:56:05 -0700 IronPort-SDR: nS9L64s7t5R4vQpINI5Y5ZhzpletvmYNGNqKG8H66PMWwQiDlUL+FeCPDG7Iip7R0hK5QDaj14 JULuPfzHQjyA== X-IronPort-AV: E=Sophos;i="5.77,433,1596524400"; d="scan'208";a="351823148" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 03:56:04 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kYS5i-001xiM-VN; Fri, 30 Oct 2020 12:57:06 +0200 Date: Fri, 30 Oct 2020 12:57:06 +0200 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , Linux Kernel Mailing List , Bartosz Golaszewski Subject: Re: [PATCH] devres: zero the memory in devm_krealloc() if needed Message-ID: <20201030105706.GK4077@smile.fi.intel.com> References: <20201026122728.8522-1-brgl@bgdev.pl> <20201026131427.GF4077@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 30, 2020 at 10:03:50AM +0100, Bartosz Golaszewski wrote: > On Thu, Oct 29, 2020 at 9:05 PM Andy Shevchenko > wrote: > > > > On Mon, Oct 26, 2020 at 01:27:28PM +0100, Bartosz Golaszewski wrote: > > > From: Bartosz Golaszewski > > > > > > If we're returning the same pointer (when new size is smaller or equal > > > to the old size) we need to check if the user wants the memory zeroed > > > and memset() it manually if so. > > > > Any use case? Because to me it sounds contradictory to the whole idea of [k]realloc(). > > This is kind of a gray area in original krealloc() too and I want to > submit a patch for mm too. Right now krealloc ignores the __GFP_ZERO > flag if new_size <= old_size but zeroes the memory if new_size > > old_size. > This should be consistent - either ignore __GFP_ZERO or > don't ignore it in both cases. I think that not ignoring it is better > - if user passes it then it's for a reason. Sorry, but I consider in these two choices the best is the former one, i.e. ignoring, because non-ignoring for sizes less than current is counter the REalloc() by definition. Reading realloc(3): "If the new size is larger than the old size, the added memory will not be initialized." So, supports my choice over yours. -- With Best Regards, Andy Shevchenko