Commit d4a3557e authored by Patrick Mochel's avatar Patrick Mochel

fix memory leak when driverfs symlink fails.

parent 309efdac
...@@ -106,13 +106,17 @@ static void fill_devpath(struct device * dev, char * path, int length) ...@@ -106,13 +106,17 @@ static void fill_devpath(struct device * dev, char * path, int length)
static int create_symlink(struct driver_dir_entry * parent, char * name, char * path) static int create_symlink(struct driver_dir_entry * parent, char * name, char * path)
{ {
struct driver_file_entry * entry; struct driver_file_entry * entry;
int error;
entry = kmalloc(sizeof(struct driver_file_entry),GFP_KERNEL); entry = kmalloc(sizeof(struct driver_file_entry),GFP_KERNEL);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
entry->name = name; entry->name = name;
entry->mode = S_IRUGO; entry->mode = S_IRUGO;
return driverfs_create_symlink(parent,entry,path); error = driverfs_create_symlink(parent,entry,path);
if (error)
kfree(entry);
return error;
} }
int device_bus_link(struct device * dev) int device_bus_link(struct device * dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment