diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2005-09-13 01:25:01 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-13 08:22:27 -0700 |
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 d164c32a97a..3b112e3542f 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -189,12 +189,11 @@ struct class *class_create(struct module *owner, char *name) struct class *cls; int retval; - cls = kmalloc(sizeof(struct class), GFP_KERNEL); + cls = kzalloc(sizeof(*cls), GFP_KERNEL); if (!cls) { retval = -ENOMEM; goto error; } - memset(cls, 0x00, sizeof(struct class)); cls->name = name; cls->owner = owner; @@ -500,13 +499,13 @@ int class_device_add(struct class_device *class_dev) /* add the needed attributes to this device */ if (MAJOR(class_dev->devt)) { struct class_device_attribute *attr; - attr = kmalloc(sizeof(*attr), GFP_KERNEL); + attr = kzalloc(sizeof(*attr), GFP_KERNEL); if (!attr) { error = -ENOMEM; kobject_del(&class_dev->kobj); goto register_done; } - memset(attr, sizeof(*attr), 0x00); + attr->attr.name = "dev"; attr->attr.mode = S_IRUGO; attr->attr.owner = parent->owner; @@ -577,12 +576,11 @@ struct class_device *class_device_create(struct class *cls, dev_t devt, if (cls == NULL || IS_ERR(cls)) goto error; - class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL); + class_dev = kzalloc(sizeof(*class_dev), GFP_KERNEL); if (!class_dev) { retval = -ENOMEM; goto error; } - memset(class_dev, 0x00, sizeof(struct class_device)); class_dev->devt = devt; class_dev->dev = device; |