diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2005-09-13 04:25:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-13 11:22:27 -0400 |
commit | 4aed0644d684428e811bb6944f032b460a3ab165 (patch) | |
tree | 4b69f949865fec1c42f7d90fb4d459483c38df5f /drivers/base/class.c | |
parent | 299cc3c166f7a11f6cc3b66aafbaf75c2aa0e0e2 (diff) |
[PATCH] drivers/base/*: use kzalloc instead of kmalloc+memset
Fixes a bunch of memset bugs too.
Signed-off-by: Lion Vollnhals <webmaster@schiggl.de>
Signed-off-by: Jiri Slaby <xslaby@fi.muni.cz>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r-- | drivers/base/class.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index d164c32a97ad..3b112e3542f8 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -189,12 +189,11 @@ struct class *class_create(struct module *owner, char *name) | |||
189 | struct class *cls; | 189 | struct class *cls; |
190 | int retval; | 190 | int retval; |
191 | 191 | ||
192 | cls = kmalloc(sizeof(struct class), GFP_KERNEL); | 192 | cls = kzalloc(sizeof(*cls), GFP_KERNEL); |
193 | if (!cls) { | 193 | if (!cls) { |
194 | retval = -ENOMEM; | 194 | retval = -ENOMEM; |
195 | goto error; | 195 | goto error; |
196 | } | 196 | } |
197 | memset(cls, 0x00, sizeof(struct class)); | ||
198 | 197 | ||
199 | cls->name = name; | 198 | cls->name = name; |
200 | cls->owner = owner; | 199 | cls->owner = owner; |
@@ -500,13 +499,13 @@ int class_device_add(struct class_device *class_dev) | |||
500 | /* add the needed attributes to this device */ | 499 | /* add the needed attributes to this device */ |
501 | if (MAJOR(class_dev->devt)) { | 500 | if (MAJOR(class_dev->devt)) { |
502 | struct class_device_attribute *attr; | 501 | struct class_device_attribute *attr; |
503 | attr = kmalloc(sizeof(*attr), GFP_KERNEL); | 502 | attr = kzalloc(sizeof(*attr), GFP_KERNEL); |
504 | if (!attr) { | 503 | if (!attr) { |
505 | error = -ENOMEM; | 504 | error = -ENOMEM; |
506 | kobject_del(&class_dev->kobj); | 505 | kobject_del(&class_dev->kobj); |
507 | goto register_done; | 506 | goto register_done; |
508 | } | 507 | } |
509 | memset(attr, sizeof(*attr), 0x00); | 508 | |
510 | attr->attr.name = "dev"; | 509 | attr->attr.name = "dev"; |
511 | attr->attr.mode = S_IRUGO; | 510 | attr->attr.mode = S_IRUGO; |
512 | attr->attr.owner = parent->owner; | 511 | attr->attr.owner = parent->owner; |
@@ -577,12 +576,11 @@ struct class_device *class_device_create(struct class *cls, dev_t devt, | |||
577 | if (cls == NULL || IS_ERR(cls)) | 576 | if (cls == NULL || IS_ERR(cls)) |
578 | goto error; | 577 | goto error; |
579 | 578 | ||
580 | class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL); | 579 | class_dev = kzalloc(sizeof(*class_dev), GFP_KERNEL); |
581 | if (!class_dev) { | 580 | if (!class_dev) { |
582 | retval = -ENOMEM; | 581 | retval = -ENOMEM; |
583 | goto error; | 582 | goto error; |
584 | } | 583 | } |
585 | memset(class_dev, 0x00, sizeof(struct class_device)); | ||
586 | 584 | ||
587 | class_dev->devt = devt; | 585 | class_dev->devt = devt; |
588 | class_dev->dev = device; | 586 | class_dev->dev = device; |