Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2604059rwd; Fri, 16 Jun 2023 06:04:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mqg/FLrlCBI1P5VIpNmpuwcd0EWa36neYeb6bF3ejc2PG/XrGKZksMoOcbd5V8URDAEet X-Received: by 2002:a05:6a20:3ca0:b0:10f:708b:bb28 with SMTP id b32-20020a056a203ca000b0010f708bbb28mr2788121pzj.7.1686920672270; Fri, 16 Jun 2023 06:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686920672; cv=none; d=google.com; s=arc-20160816; b=DHoQU+1mAB9ckbQb5TPCC5Iiy0oBUiPLXn95bSVTtiJnXA+I2Y3HMPrPigs3se6UWr 56QerEO2SuRcsdAIy0yRmu/S4KavvitiHNQ5XaA31RWZvEMNsDD2o/YJxfFKaWq0sjSs dASAPQFT1i+ajDq3Q+ra2TFEMxJMPpQWItQqzgJSYxUHlGqK8YMAFD5JFhsHv4gY0D9s VFwdfltXJl/snm499RtjOXh+VUQ3mQxSgHwcQumPUsWDqT2nwZvdMbg3JgG8TYz1pIhi uH7xBr8f2CH/4JnKEknoo11ZqKb6k8m1rdyNdyG2jN4m95GnnlCw9/4/7KH5rIHqpYHO 1Ogg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wMPZm18GVVIibQKQ6xh29CFwbcIj8kHzRGjqF9oTRCc=; b=rQoxE6CnzCZXEWFo9NdFYFK76N6CGPc+PGFDedrbYNlDWzwl1k5NUmI3kmR8z6cuX1 OjENW8K6rJ0EFUJha7KYTI+d5wBuctHca/LB9wf8jMRwOjkIWiGaaBg9BI5Hj8dR2jXV 3yHrEW0ypkc1+chSGXsjl6l7ThwG2CfXoryN2qsxDkaXl9+oG4HoVbKA62ZZTTWOoLm3 mO0EP6rN4PrFZClsNavXl17Mudm0ZlUqxZWzer3hvRXsnUd57DRHkCnOJlYwHXSCai4Q QZdYqBh4UCuYW5YLINiy/xIBqOeEgzVcov7mg5OoeulbnguLWjIiaj1sEsn9KzLu0yQR tomA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a187-20020a6390c4000000b0055381821b9esi663449pge.806.2023.06.16.06.04.17; Fri, 16 Jun 2023 06:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343653AbjFPMcL (ORCPT + 99 others); Fri, 16 Jun 2023 08:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjFPMcK (ORCPT ); Fri, 16 Jun 2023 08:32:10 -0400 Received: from 5.mo562.mail-out.ovh.net (5.mo562.mail-out.ovh.net [46.105.48.192]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772CF212C for ; Fri, 16 Jun 2023 05:32:07 -0700 (PDT) Received: from director1.derp.mail-out.ovh.net (director1.derp.mail-out.ovh.net [51.68.80.175]) by mo562.mail-out.ovh.net (Postfix) with ESMTPS id 4F71323F51; Fri, 16 Jun 2023 09:57:55 +0000 (UTC) Received: from director1.derp.mail-out.ovh.net (director1.derp.mail-out.ovh.net. [127.0.0.1]) by director1.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for ; Fri, 16 Jun 2023 09:57:55 +0000 (UTC) Received: from pro2.mail.ovh.net (unknown [10.108.20.117]) by director1.derp.mail-out.ovh.net (Postfix) with ESMTPS id E62A81FA43E; Fri, 16 Jun 2023 09:57:54 +0000 (UTC) Received: from traphandler.com (88.161.25.233) by DAG1EX1.emp2.local (172.16.2.1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 16 Jun 2023 11:57:54 +0200 From: Jean-Jacques Hiblot To: , , , , CC: , , , Jean-Jacques Hiblot , Andy Shevchenko Subject: [PATCH v9 1/5] devres: provide devm_krealloc_array() Date: Fri, 16 Jun 2023 11:57:42 +0200 Message-ID: <20230616095746.872220-2-jjhiblot@traphandler.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616095746.872220-1-jjhiblot@traphandler.com> References: <20230616095746.872220-1-jjhiblot@traphandler.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [88.161.25.233] X-ClientProxiedBy: CAS3.emp2.local (172.16.1.3) To DAG1EX1.emp2.local (172.16.2.1) X-Ovh-Tracer-Id: 3612731326956714375 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrgedvgedgvddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfgtihesthekredtredttdenucfhrhhomheplfgvrghnqdflrggtqhhuvghsucfjihgslhhothcuoehjjhhhihgslhhothesthhrrghphhgrnhgulhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepudetveelveevgffgvdeuffffjefhheehueeitdegtdejgefhheeuuddugeeffeeunecukfhppedtrddtrddtrddtpdekkedrudeiuddrvdehrddvfeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopeguihhrvggtthhorhdurdguvghrphdrmhgrihhlqdhouhhtrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpehjjhhhihgslhhothesthhrrghphhgrnhgulhgvrhdrtghomhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhlvggushesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheeivd X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement the managed variant of krealloc_array(). This internally uses devm_krealloc() and as such is usable with all memory allocated by devm_kmalloc() (or devres functions using it implicitly like devm_kmemdup(), devm_kstrdup() etc.). Managed realloc'ed chunks can be manually released with devm_kfree(). Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Andy Shevchenko --- include/linux/device.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 472dd24d4823..e45dc78068b7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -223,6 +223,19 @@ static inline void *devm_kcalloc(struct device *dev, { return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); } +static inline void *devm_krealloc_array(struct device *dev, + void *p, + size_t new_n, + size_t new_size, + gfp_t flags) +{ + size_t bytes; + + if (unlikely(check_mul_overflow(new_n, new_size, &bytes))) + return NULL; + + return devm_krealloc(dev, p, bytes, flags); +} void devm_kfree(struct device *dev, const void *p); char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc; const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp); -- 2.34.1