Linux-Doc Archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] devres: Provide krealloc_array
@ 2023-05-09  9:49 James Clark
  2023-05-09  9:49 ` [PATCH v4 1/4] " James Clark
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: James Clark @ 2023-05-09  9:49 UTC (permalink / raw
  To: linux-kernel, gregkh
  Cc: linux, michal.simek, Jonathan.Cameron, James Clark,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial

Changes since v3:

 * Rebase onto v6.4-rc1

Changes since v2:
 
 * Remove change in qcom_geni_serial.c in the last commmit and replace
   it with a comment instead
 * Whitespace fix

Changes since v1:

 * Style fix

-----------------------

Hi,

I had a use for a devm realloc_array in a separate change, so I've
added one and updated all the obvious existing uses of it that I could
find. This is basically a copy paste of the one in slab.h

Applies to v6.4-rc1

Thanks
James
James Clark (4):
  devres: Provide krealloc_array
  hwmon: pmbus: Use devm_krealloc_array
  iio: adc: Use devm_krealloc_array
  serial: qcom_geni: Comment use of devm_krealloc rather than
    devm_krealloc_array

 .../driver-api/driver-model/devres.rst          |  1 +
 drivers/hwmon/pmbus/pmbus_core.c                |  6 +++---
 drivers/iio/adc/xilinx-ams.c                    |  9 +++------
 drivers/iio/adc/xilinx-xadc-core.c              | 17 +++++++----------
 drivers/tty/serial/qcom_geni_serial.c           |  5 +++++
 include/linux/device.h                          | 11 +++++++++++
 6 files changed, 30 insertions(+), 19 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 1/4] devres: Provide krealloc_array
  2023-05-09  9:49 [PATCH v4 0/4] devres: Provide krealloc_array James Clark
@ 2023-05-09  9:49 ` James Clark
  2023-05-13 11:04   ` Greg KH
  2023-05-09  9:49 ` [PATCH v4 2/4] hwmon: pmbus: Use devm_krealloc_array James Clark
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: James Clark @ 2023-05-09  9:49 UTC (permalink / raw
  To: linux-kernel, gregkh
  Cc: linux, michal.simek, Jonathan.Cameron, James Clark,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial

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 <Jonathan.Cameron@huawei.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 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
+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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 2/4] hwmon: pmbus: Use devm_krealloc_array
  2023-05-09  9:49 [PATCH v4 0/4] devres: Provide krealloc_array James Clark
  2023-05-09  9:49 ` [PATCH v4 1/4] " James Clark
@ 2023-05-09  9:49 ` James Clark
  2023-05-09  9:49 ` [PATCH v4 3/4] iio: adc: " James Clark
  2023-05-09  9:49 ` [PATCH v4 4/4] serial: qcom_geni: Comment use of devm_krealloc rather than devm_krealloc_array James Clark
  3 siblings, 0 replies; 8+ messages in thread
From: James Clark @ 2023-05-09  9:49 UTC (permalink / raw
  To: linux-kernel, gregkh
  Cc: linux, michal.simek, Jonathan.Cameron, James Clark,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial

Now that it exists, use it instead of doing the multiplication manually.

Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 drivers/hwmon/pmbus/pmbus_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 9d14954da94f..fa06325f5a7c 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1191,9 +1191,9 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
 {
 	if (data->num_attributes >= data->max_attributes - 1) {
 		int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE;
-		void *new_attrs = devm_krealloc(data->dev, data->group.attrs,
-						new_max_attrs * sizeof(void *),
-						GFP_KERNEL);
+		void *new_attrs = devm_krealloc_array(data->dev, data->group.attrs,
+						      new_max_attrs, sizeof(void *),
+						      GFP_KERNEL);
 		if (!new_attrs)
 			return -ENOMEM;
 		data->group.attrs = new_attrs;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 3/4] iio: adc: Use devm_krealloc_array
  2023-05-09  9:49 [PATCH v4 0/4] devres: Provide krealloc_array James Clark
  2023-05-09  9:49 ` [PATCH v4 1/4] " James Clark
  2023-05-09  9:49 ` [PATCH v4 2/4] hwmon: pmbus: Use devm_krealloc_array James Clark
@ 2023-05-09  9:49 ` James Clark
  2023-05-09  9:49 ` [PATCH v4 4/4] serial: qcom_geni: Comment use of devm_krealloc rather than devm_krealloc_array James Clark
  3 siblings, 0 replies; 8+ messages in thread
From: James Clark @ 2023-05-09  9:49 UTC (permalink / raw
  To: linux-kernel, gregkh
  Cc: linux, michal.simek, Jonathan.Cameron, James Clark,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial

Now that it exists, use it instead of doing the multiplication and
checking for overflow manually.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 drivers/iio/adc/xilinx-ams.c       |  9 +++------
 drivers/iio/adc/xilinx-xadc-core.c | 17 +++++++----------
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
index 34cf336b3490..f0b71a1220e0 100644
--- a/drivers/iio/adc/xilinx-ams.c
+++ b/drivers/iio/adc/xilinx-ams.c
@@ -1263,7 +1263,7 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
 	struct device *dev = indio_dev->dev.parent;
 	struct fwnode_handle *child = NULL;
 	struct fwnode_handle *fwnode = dev_fwnode(dev);
-	size_t ams_size, dev_size;
+	size_t ams_size;
 	int ret, ch_cnt = 0, i, rising_off, falling_off;
 	unsigned int num_channels = 0;
 
@@ -1320,11 +1320,8 @@ static int ams_parse_firmware(struct iio_dev *indio_dev)
 		}
 	}
 
-	dev_size = array_size(sizeof(*dev_channels), num_channels);
-	if (dev_size == SIZE_MAX)
-		return -ENOMEM;
-
-	dev_channels = devm_krealloc(dev, ams_channels, dev_size, GFP_KERNEL);
+	dev_channels = devm_krealloc_array(dev, ams_channels, num_channels,
+					   sizeof(*dev_channels), GFP_KERNEL);
 	if (!dev_channels)
 		return -ENOMEM;
 
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 292f2892d223..dba73300f894 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -613,20 +613,17 @@ static int xadc_update_scan_mode(struct iio_dev *indio_dev,
 	const unsigned long *mask)
 {
 	struct xadc *xadc = iio_priv(indio_dev);
-	size_t new_size, n;
+	size_t n;
 	void *data;
 
 	n = bitmap_weight(mask, indio_dev->masklength);
 
-	if (check_mul_overflow(n, sizeof(*xadc->data), &new_size))
-		return -ENOMEM;
-
-	data = devm_krealloc(indio_dev->dev.parent, xadc->data,
-			     new_size, GFP_KERNEL);
+	data = devm_krealloc_array(indio_dev->dev.parent, xadc->data,
+				   n, sizeof(*xadc->data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	memset(data, 0, new_size);
+	memset(data, 0, n * sizeof(*xadc->data));
 	xadc->data = data;
 
 	return 0;
@@ -1281,9 +1278,9 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, unsigned int *conf, int irq)
 	}
 
 	indio_dev->num_channels = num_channels;
-	indio_dev->channels = devm_krealloc(dev, channels,
-					    sizeof(*channels) * num_channels,
-					    GFP_KERNEL);
+	indio_dev->channels = devm_krealloc_array(dev, channels,
+						  num_channels, sizeof(*channels),
+						  GFP_KERNEL);
 	/* If we can't resize the channels array, just use the original */
 	if (!indio_dev->channels)
 		indio_dev->channels = channels;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 4/4] serial: qcom_geni: Comment use of devm_krealloc rather than devm_krealloc_array
  2023-05-09  9:49 [PATCH v4 0/4] devres: Provide krealloc_array James Clark
                   ` (2 preceding siblings ...)
  2023-05-09  9:49 ` [PATCH v4 3/4] iio: adc: " James Clark
@ 2023-05-09  9:49 ` James Clark
  3 siblings, 0 replies; 8+ messages in thread
From: James Clark @ 2023-05-09  9:49 UTC (permalink / raw
  To: linux-kernel, gregkh
  Cc: linux, michal.simek, Jonathan.Cameron, James Clark,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial

Now that devm_krealloc_array is available, add a comment justifying not
changing this occurrence to avoid any future auto fixups.

Link: https://lore.kernel.org/all/20230318173402.20a4f60d@jic23-huawei/
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 drivers/tty/serial/qcom_geni_serial.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 08dc3e2a729c..3a6cf762449f 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1053,6 +1053,11 @@ static int setup_fifos(struct qcom_geni_serial_port *port)
 		(port->tx_fifo_depth * port->tx_fifo_width) / BITS_PER_BYTE;
 
 	if (port->rx_buf && (old_rx_fifo_depth != port->rx_fifo_depth) && port->rx_fifo_depth) {
+		/*
+		 * Use krealloc rather than krealloc_array because rx_buf is
+		 * accessed as 1 byte entries as well as 4 byte entries so it's
+		 * not necessarily an array.
+		 */
 		port->rx_buf = devm_krealloc(uport->dev, port->rx_buf,
 					     port->rx_fifo_depth * sizeof(u32),
 					     GFP_KERNEL);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 1/4] devres: Provide krealloc_array
  2023-05-09  9:49 ` [PATCH v4 1/4] " James Clark
@ 2023-05-13 11:04   ` Greg KH
  2023-05-15  7:55     ` James Clark
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2023-05-13 11:04 UTC (permalink / raw
  To: James Clark
  Cc: linux-kernel, linux, michal.simek, Jonathan.Cameron,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial

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 <Jonathan.Cameron@huawei.com>
> Signed-off-by: James Clark <james.clark@arm.com>
> ---
>  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?

> +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.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 1/4] devres: Provide krealloc_array
  2023-05-13 11:04   ` Greg KH
@ 2023-05-15  7:55     ` James Clark
  2023-05-15 11:55       ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: James Clark @ 2023-05-15  7:55 UTC (permalink / raw
  To: Greg KH
  Cc: linux-kernel, linux, michal.simek, Jonathan.Cameron,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial



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 <Jonathan.Cameron@huawei.com>
>> Signed-off-by: James Clark <james.clark@arm.com>
>> ---
>>  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?

> 
>> +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.

Thanks
James

> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 1/4] devres: Provide krealloc_array
  2023-05-15  7:55     ` James Clark
@ 2023-05-15 11:55       ` Greg KH
  0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2023-05-15 11:55 UTC (permalink / raw
  To: James Clark
  Cc: linux-kernel, linux, michal.simek, Jonathan.Cameron,
	Jonathan Corbet, Jean Delvare, Anand Ashok Dumbre,
	Jonathan Cameron, Lars-Peter Clausen, Andy Gross, Bjorn Andersson,
	Konrad Dybcio, Jiri Slaby, linux-doc, linux-hwmon, linux-iio,
	linux-arm-kernel, linux-arm-msm, linux-serial

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 <Jonathan.Cameron@huawei.com>
> >> Signed-off-by: James Clark <james.clark@arm.com>
> >> ---
> >>  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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-15 11:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-09  9:49 [PATCH v4 0/4] devres: Provide krealloc_array James Clark
2023-05-09  9:49 ` [PATCH v4 1/4] " James Clark
2023-05-13 11:04   ` Greg KH
2023-05-15  7:55     ` James Clark
2023-05-15 11:55       ` Greg KH
2023-05-09  9:49 ` [PATCH v4 2/4] hwmon: pmbus: Use devm_krealloc_array James Clark
2023-05-09  9:49 ` [PATCH v4 3/4] iio: adc: " James Clark
2023-05-09  9:49 ` [PATCH v4 4/4] serial: qcom_geni: Comment use of devm_krealloc rather than devm_krealloc_array James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).