static struct kobj_attribute* create_attribute(const char* _name, umode_t _mode) { char* attr_name; struct kobj_attribute* _attr; _attr = kzalloc(sizeof(struct kobj_attribute), GFP_KERNEL); if (! _attr) { log_error("kzalloc of attribute %s failed", _name); return NULL; } sysfs_attr_init(_attr); attr_name = kstrdup(_name, GFP_KERNEL); if (! attr_name) { log_error("GFP_KERNEL dup failed for attribute [%s]", _name); return NULL; } _attr->attr.name = attr_name; _attr->attr.mode = _mode; return _attr; }