[PATCH v2 2/5] libusbg: Fix wrong malloc sizes in allocate functions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Functions usbg_allocate_function() and usbg_allocate_binding()
had allocated sizeof(usbg_config) instead of usbg_function
and usbg_binding.

Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
 src/usbg.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/usbg.c b/src/usbg.c
index e472463..fa8dece 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -482,7 +482,7 @@ static usbg_gadget *usbg_allocate_gadget(char *path, char *name,
 {
 	usbg_gadget *g;
 
-	g = malloc(sizeof(usbg_gadget));
+	g = malloc(sizeof(*g));
 	if (g) {
 		TAILQ_INIT(&g->functions);
 		TAILQ_INIT(&g->configs);
@@ -506,7 +506,7 @@ static usbg_config *usbg_allocate_config(char *path, char *name,
 {
 	usbg_config *c;
 
-	c = malloc(sizeof(usbg_config));
+	c = malloc(sizeof(*c));
 	if (c) {
 		TAILQ_INIT(&c->bindings);
 		c->name = strdup(name);
@@ -529,7 +529,7 @@ static usbg_function *usbg_allocate_function(char *path, char *name,
 {
 	usbg_function *f;
 
-	f = malloc(sizeof(usbg_config));
+	f = malloc(sizeof(*f));
 	if (f) {
 		f->name = strdup(name);
 		f->path = strdup(path);
@@ -551,7 +551,7 @@ static usbg_binding *usbg_allocate_binding(char *path, char *name,
 {
 	usbg_binding *b;
 
-	b = malloc(sizeof(usbg_config));
+	b = malloc(sizeof(*b));
 	if (b) {
 		b->name = strdup(name);
 		b->path = strdup(path);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux