lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 20 Jan 2019 11:03:52 +0100
From:   Jiri Pirko <jiri@...nulli.us>
To:     Eran Ben Elisha <eranbe@...lanox.com>
Cc:     netdev@...r.kernel.org, Jiri Pirko <jiri@...lanox.com>,
        "David S. Miller" <davem@...emloft.net>,
        Ariel Almog <ariela@...lanox.com>,
        Aya Levin <ayal@...lanox.com>,
        Moshe Shemesh <moshe@...lanox.com>
Subject: Re: [PATCH net-next v2 01/11] devlink: Add health buffer support

Thu, Jan 17, 2019 at 10:59:10PM CET, eranbe@...lanox.com 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]);
>+	}
>+}
>+

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ