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=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham 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 0A69FC5519F for ; Sat, 14 Nov 2020 15:48:47 +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 9794922254 for ; Sat, 14 Nov 2020 15:48:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="s/Q71nr6"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="TwG4XwTi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9794922254 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:MIME-Version:References:In-Reply-To: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=EzF53fWeday92dvkQNH/8RBGahejQi1Lihm+ibdt+vI=; b=s/Q71nr6mLn4k/t34pXKUf1Df aC+9PH9hRySpLYJAFKhAlq4X0SlLurUgFE6KPl5CLPSwxCDi8OlZOevRMWFZ5Nrty5hrC7ghLyDLB myJc0DL9wCLvQkW9hwpX6XdRnSCto1/K7KsdczO6G6XzO/QKKrbaWQgiMkLrYHfgzpjSN83IvuZdX IzYymLbw9iV4Jzve9oRz3c/Xc/PyRqxU4uRkpGnrnSCTzwbRFQKMNDGAYtm8BUFQnn8OMRvoUsXP3 T1E3gheZ+7eIhSgywFjcuqXH2AhOX1hZXhBdOj5gV+cmm3Ji+5Zza7x7X78HRouqTKIZvFDrNRV3V +h6cUooRw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdxlJ-00060p-RS; Sat, 14 Nov 2020 15:46:49 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdxlH-00060W-6f for linux-arm-kernel@lists.infradead.org; Sat, 14 Nov 2020 15:46:48 +0000 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69B4522254; Sat, 14 Nov 2020 15:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605368806; bh=goHaolbjw30a+EKdHtSQX6pyt5XC1BydKi65tudi8MU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TwG4XwTitBBCcrpR8+kmM/0aTv9tvgTIRPnygVP4/I5RGNYKJKN0Tf+yP5idzt2aR HqYVW1XDcVYksnkogG7/mUPcwya8GXjbPxTQ/hhe6GnekdZ/Y0LTpaXZob8uiLnWrr 1TYS+w1rkbhw/yDwc3O3iZjxCHLspQQVYarqU250= Date: Sat, 14 Nov 2020 15:46:41 +0000 From: Jonathan Cameron To: Bartosz Golaszewski Subject: Re: [PATCH v2 1/4] device: provide devm_krealloc_array() Message-ID: <20201114154641.0258f4ee@archlinux> In-Reply-To: <20201102142228.14949-2-brgl@bgdev.pl> References: <20201102142228.14949-1-brgl@bgdev.pl> <20201102142228.14949-2-brgl@bgdev.pl> X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201114_104647_335718_203175F6 X-CRM114-Status: GOOD ( 19.63 ) 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: Lars-Peter Clausen , linux-iio@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, Michal Simek , Bartosz Golaszewski , Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org 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, 2 Nov 2020 15:22:25 +0100 Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > When allocating an array of elements, users should check for > multiplication overflow or preferably use one of the provided helpers > like: devm_kmalloc_array(). > > This provides devm_krealloc_array() for users who want to reallocate > managed arrays. > > Signed-off-by: Bartosz Golaszewski +CC Greg KH. As this is going into a very generic place I'd like a relevant ack. That file is a bit of a wild west for acks, but Greg seems most appropriate person. So Greg, any comments on this one? Thanks, Jonathan > --- > include/linux/device.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/include/linux/device.h b/include/linux/device.h > index 5ed101be7b2e..e77203faea55 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -226,6 +226,17 @@ static inline void *devm_kmalloc_array(struct device *dev, > > return devm_kmalloc(dev, bytes, flags); > } > +static inline void * > +devm_krealloc_array(struct device *dev, void *ptr, size_t new_n, > + size_t new_size, gfp_t gfp) > +{ > + size_t bytes; > + > + if (unlikely(check_mul_overflow(new_n, new_size, &bytes))) > + return NULL; > + > + return devm_krealloc(dev, ptr, bytes, gfp); > +} > static inline void *devm_kcalloc(struct device *dev, > size_t n, size_t size, gfp_t flags) > { _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel