Subject: Re: [PATCH net-next v2 01/11] devlink: Add health buffer support

From: Jiri Pirko <[email-masked]>
Date: Sun, 20 Jan 2019 12:08:50 +0100

Sun, Jan 20, 2019 at 12:06:18PM CET, [email-masked] wrote:
>
>
>On 1/20/2019 12:03 PM, Jiri Pirko wrote:
>> Thu, Jan 17, 2019 at 10:59:10PM CET, [email-masked] wrote:
>> 
>> [...]
>> 
>>> +static void
>>> +devlink_health_buffers_destroy(struct devlink_health_buffer **buffers_list,
>>> +			       u64 size);
>> 
>> Avoid fwd declarations.
>> 
>> 
>>> +
>>> +static struct devlink_health_buffer **
>>> +devlink_health_buffers_create(u64 size)
>>> +{
>>> +	struct devlink_health_buffer **buffers_list;
>>> +	u64 num_of_buffers = DEVLINK_HEALTH_SIZE_TO_BUFFERS(size);
>>> +	u64 i;
>>> +
>>> +	buffers_list = kcalloc(num_of_buffers,
>>> +			       sizeof(struct devlink_health_buffer *),
>>> +			       GFP_KERNEL);
>>> +	if (!buffers_list)
>>> +		return NULL;
>>> +
>>> +	for (i = 0; i < num_of_buffers; i++) {
>>> +		struct devlink_health_buffer *buffer;
>>> +		void *data;
>>> +
>>> +		buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
>>> +		data = kzalloc(DEVLINK_HEALTH_BUFFER_SIZE, GFP_KERNEL);
>>> +		if (!buffer || !data) {
>>> +			kfree(buffer);
>>> +			kfree(data);
>>> +			goto buffers_cleanup;
>>> +		}
>>> +		buffers_list[i] = buffer;
>>> +		buffer->data = data;
>>> +	}
>>> +	devlink_health_buffers_reset(buffers_list, num_of_buffers);
>>> +
>>> +	return buffers_list;
>>> +
>>> +buffers_cleanup:
>>> +	devlink_health_buffers_destroy(buffers_list, --i);
>> 
>> Just do for-kfree here.
>> 
>> 
>>> +	kfree(buffers_list);
>>> +	return NULL;
>>> +}
>>> +
>>> +static void
>>> +devlink_health_buffers_destroy(struct devlink_health_buffer **buffers_list,
>>> +			       u64 num_of_buffers)
>>> +{
>>> +	u64 i;
>>> +
>>> +	for (i = 0; i < num_of_buffers; i++) {
>>> +		kfree(buffers_list[i]->data);
>>> +		kfree(buffers_list[i]);
>>> +	}
>>> +}
>>> +
>> 
>> [...]
>> 
>
>Hi Jiri,
>The series is merged. I can take the relevant comments as send as fix 
>with the rest of the series if you wish to.

I haven't have time to review this due to travel. I think it was mistake
to merge this as the buffer api is wrong in my opinion. I would vote for
revert if possible.