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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DA1DC7EE22 for ; Mon, 15 May 2023 11:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=tuq84a/dppFM4F3IjQqBHvIuA80DyeBrFkrL5JwRmQk=; b=25NymOynn/0U3e 4X/rj3E7JXiteJ8D91cYDy3ILLlJGcdJP4ObGs6bAL+PTVGpPU5eH5kyXq5uffBliXl81DoIkSWBv V11LKtBc/l62FwdizrMcaXdDZu1TkXbFm67u2RTWvYBTMV9voqBwKLm5dGFOsGRg40L/7qzN5qrgK e32QJx0VW+MZGLbojVFeZNKs9LrtIx4AVMdJU+fZhT6FYTFyzb1v1sk5NWnK2IdEKJS44/UFrr9VF fwwQHL7xyxiH6F3FZlCNRn2+3hTdjyqI6oj2u9su0yp3VtaiYjGfOsEMfsJi7yGPGiO7EYdh7FULb T9KWi9ascSdDWJhss5ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyWnT-0022y9-1G; Mon, 15 May 2023 11:55:23 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyWnQ-0022xD-0k for linux-arm-kernel@lists.infradead.org; Mon, 15 May 2023 11:55:21 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C9EE62319; Mon, 15 May 2023 11:55:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74BDAC4339E; Mon, 15 May 2023 11:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684151719; bh=LM25J4KXPt/WwdGCWg9t6HOTk+4FHz+nzlXEdIACN18=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ytX9itB6cmA/S/w3NnY7T9t+f3m7iFGkc9RX9/gTRkP+L2NMqoXGbWx5yM8gIDhqW DmwR3Ru+tm95NbuH3zNF/uB9dkKlLR4uLj0+zQz1JGxRsBmjR64nW4aIlm74xBPWaM ibHRNb0kzhWgcE7DVopBy0yPsVXYadJZIoXdlbDc= Date: Mon, 15 May 2023 13:55:16 +0200 From: Greg KH To: James Clark Cc: linux-kernel@vger.kernel.org, linux@roeck-us.net, michal.simek@amd.com, Jonathan.Cameron@huawei.com, Jonathan Corbet , Jean Delvare , Anand Ashok Dumbre , Jonathan Cameron , Lars-Peter Clausen , Andy Gross , Bjorn Andersson , Konrad Dybcio , Jiri Slaby , linux-doc@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH v4 1/4] devres: Provide krealloc_array Message-ID: <2023051530-immunize-pony-49ef@gregkh> References: <20230509094942.396150-1-james.clark@arm.com> <20230509094942.396150-2-james.clark@arm.com> <2023051340-sinuous-darkroom-2497@gregkh> <89ad5070-db72-7bf1-5d86-a89fea54e789@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <89ad5070-db72-7bf1-5d86-a89fea54e789@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_045520_361418_E12D901E X-CRM114-Status: GOOD ( 28.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, May 15, 2023 at 08:55:33AM +0100, James Clark wrote: > > > On 13/05/2023 12:04, Greg KH wrote: > > On Tue, May 09, 2023 at 10:49:38AM +0100, James Clark wrote: > >> There is no krealloc_array equivalent in devres. Users would have to > >> do their own multiplication overflow check so provide one. > >> > >> Reviewed-by: Jonathan Cameron > >> Signed-off-by: James Clark > >> --- > >> Documentation/driver-api/driver-model/devres.rst | 1 + > >> include/linux/device.h | 11 +++++++++++ > >> 2 files changed, 12 insertions(+) > >> > >> diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst > >> index 4249eb4239e0..8be086b3f829 100644 > >> --- a/Documentation/driver-api/driver-model/devres.rst > >> +++ b/Documentation/driver-api/driver-model/devres.rst > >> @@ -364,6 +364,7 @@ MEM > >> devm_kmalloc_array() > >> devm_kmemdup() > >> devm_krealloc() > >> + devm_krealloc_array() > >> devm_kstrdup() > >> devm_kstrdup_const() > >> devm_kvasprintf() > >> diff --git a/include/linux/device.h b/include/linux/device.h > >> index 472dd24d4823..58f4f5948edb 100644 > >> --- a/include/linux/device.h > >> +++ b/include/linux/device.h > >> @@ -223,6 +223,17 @@ static inline void *devm_kcalloc(struct device *dev, > >> { > >> return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); > >> } > >> +static inline __realloc_size(3, 4) void * __must_check > > > > Shouldn't you have a blank line before this one? > > I was going for consistency with the rest of this section which doesn't > have newlines between the functions for some reason. I can add one and > resubmit but it might look a bit out of place? Ah, wasn't aware of that, given the lack of context. So nevermind, it's fine for now. > >> +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); > >> +} > > > > I dislike how we have to keep copying the "real" functions (i.e. > > krealloc_array) into something like this, but I can't think of a better > > way to do it. > > > > Maybe something could be done with some macro magic, but it would > probably end up being worse than just copying them and would affect the > real ones as well. So yeah I can't think of any easy gains either. Ok, that's good. Given a lack of objections from others, I'll just take this through my driver core tree in a few days. thanks, greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel