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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 7A05FC433DF for ; Tue, 18 Aug 2020 08:41:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27A172067C for ; Tue, 18 Aug 2020 08:41:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ConMNTRp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27A172067C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=O5Mo5KVJViAqxClHdvNmRGmOEgbLDxCpvDkh/NfcTLA=; b=ConMNTRpIdhuWLmjISr/dYzBj 5rerQGqnSFnHeqJnz91TV3icqXjXtsw3YMigUJF9YlqLrF5+Ncil7k58hGWr9B0YFEq20eZn6gtGN ok0GjJoYshbQtYZTTkaRfow0FrS4QXzMRu0v3idDrBURN7kbh8A+8zrn1m6moeOi+WqrJur80eI3P ErPoAaZVIKGup5Avi4ULMBxOqd6OGk9dw2TgBZUhYeCx+Xf9dtW9+iLRKUmAvkTV+QTTJ9pRuWFDe 1dt6UMiLOQrG+iewuH1c+ISK+sLqoqZiKdOvoCGwdIGHNID6dkcO48cgL3eamRw+2YzAr9j2nefgs s3IeTpLhg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7xAQ-0007ej-Vz; Tue, 18 Aug 2020 08:40:28 +0000 Received: from mga11.intel.com ([192.55.52.93]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7xAN-0007e1-W7 for linux-arm-kernel@lists.infradead.org; Tue, 18 Aug 2020 08:40:24 +0000 IronPort-SDR: KwBlYXissUbG2uRGayap4Gc0vtZbm0vCXpu8ojlgzw3+vQVt02m1bt9hOJ7CHpzgYdHjtxwKMh 4FDn1ba7idcw== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152495478" X-IronPort-AV: E=Sophos;i="5.76,326,1592895600"; d="scan'208";a="152495478" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 01:40:22 -0700 IronPort-SDR: ZfQNn4ykMKuJGH4oqBnip9509BvoKhkE19++1eEWzlMEvYjXDHPJxm35N6ah0BYqxebZvr2VV2 J3r5/xOjR9zA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,326,1592895600"; d="scan'208";a="326668086" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 18 Aug 2020 01:40:19 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1k7wvU-009bYR-P5; Tue, 18 Aug 2020 11:25:00 +0300 Date: Tue, 18 Aug 2020 11:25:00 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Subject: Re: [PATCH v7 1/3] devres: provide devm_krealloc() Message-ID: <20200818082500.GB1891694@smile.fi.intel.com> References: <20200817170535.17041-1-brgl@bgdev.pl> <20200817170535.17041-2-brgl@bgdev.pl> <20200817173908.GS1891694@smile.fi.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200818_044024_175300_AD0B491D X-CRM114-Status: GOOD ( 24.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux ARM , Lars-Peter Clausen , linux-iio , Greg Kroah-Hartman , Michal Simek , Linux Kernel Mailing List , Bartosz Golaszewski , Guenter Roeck , Peter Meerwald-Stadler , Hartmut Knaack , Jonathan Cameron Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Aug 17, 2020 at 10:02:05PM +0200, Bartosz Golaszewski wrote: > On Mon, Aug 17, 2020 at 7:43 PM Andy Shevchenko > wrote: > > On Mon, Aug 17, 2020 at 07:05:33PM +0200, Bartosz Golaszewski wrote: > > > From: Bartosz Golaszewski ... > > > +static struct devres *to_devres(void *data) > > > +{ > > > + return (struct devres *)((u8 *)data - ALIGN(sizeof(struct devres), > > > + ARCH_KMALLOC_MINALIGN)); > > > > Do you really need both explicit castings? > > > > Yeah, we can probably drop the (struct devres *) here. void * -> u8 * here is also not needed, it is considered byte access IIRC. > > > +} ... > > - hasn't gone while you run a ksize()? > At some point you need to draw a line. In the end: how do you > guarantee a devres buffer hasn't been freed when you're using it? In > my comment to the previous version of this patch I clarified that we > need to protect all modifications of the devres linked list - we must > not realloc a chunk that contains the links without taking the > spinlock but also we must not call alloc() funcs with GFP_KERNEL with > spinlock taken. The issue we could run into is: someone modifies the > linked list by adding/removing other managed resources, not modifying > this one. > > The way this function works now guarantees it but other than that: > it's up to the users to not free memory they're actively using. Thanks for clarification. I agree. -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel