mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-15 21:30:43 +00:00
ACPI: video - properly handle errors when registering proc elements
Have acpi_video_device_add_fs() and acpi_video_bus_add_fs() properly unwind proc creation after error. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Acked-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
78eed028f1
commit
251cb0bc79
@ -1048,87 +1048,90 @@ acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file)
|
|||||||
|
|
||||||
static int acpi_video_device_add_fs(struct acpi_device *device)
|
static int acpi_video_device_add_fs(struct acpi_device *device)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *entry = NULL;
|
struct proc_dir_entry *entry, *device_dir;
|
||||||
struct acpi_video_device *vid_dev;
|
struct acpi_video_device *vid_dev;
|
||||||
|
|
||||||
|
|
||||||
if (!device)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
vid_dev = acpi_driver_data(device);
|
vid_dev = acpi_driver_data(device);
|
||||||
if (!vid_dev)
|
if (!vid_dev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (!acpi_device_dir(device)) {
|
device_dir = proc_mkdir(acpi_device_bid(device),
|
||||||
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
|
vid_dev->video->dir);
|
||||||
vid_dev->video->dir);
|
if (!device_dir)
|
||||||
if (!acpi_device_dir(device))
|
return -ENOMEM;
|
||||||
return -ENODEV;
|
|
||||||
acpi_device_dir(device)->owner = THIS_MODULE;
|
device_dir->owner = THIS_MODULE;
|
||||||
}
|
|
||||||
|
|
||||||
/* 'info' [R] */
|
/* 'info' [R] */
|
||||||
entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
|
entry = create_proc_entry("info", S_IRUGO, device_dir);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_dir;
|
||||||
else {
|
|
||||||
entry->proc_fops = &acpi_video_device_info_fops;
|
entry->proc_fops = &acpi_video_device_info_fops;
|
||||||
entry->data = acpi_driver_data(device);
|
entry->data = acpi_driver_data(device);
|
||||||
entry->owner = THIS_MODULE;
|
entry->owner = THIS_MODULE;
|
||||||
}
|
|
||||||
|
|
||||||
/* 'state' [R/W] */
|
/* 'state' [R/W] */
|
||||||
entry =
|
entry = create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
|
||||||
create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
|
device_dir);
|
||||||
acpi_device_dir(device));
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_info;
|
||||||
else {
|
|
||||||
acpi_video_device_state_fops.write = acpi_video_device_write_state;
|
acpi_video_device_state_fops.write = acpi_video_device_write_state;
|
||||||
entry->proc_fops = &acpi_video_device_state_fops;
|
entry->proc_fops = &acpi_video_device_state_fops;
|
||||||
entry->data = acpi_driver_data(device);
|
entry->data = acpi_driver_data(device);
|
||||||
entry->owner = THIS_MODULE;
|
entry->owner = THIS_MODULE;
|
||||||
}
|
|
||||||
|
|
||||||
/* 'brightness' [R/W] */
|
/* 'brightness' [R/W] */
|
||||||
entry =
|
entry = create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
|
||||||
create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
|
device_dir);
|
||||||
acpi_device_dir(device));
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_state;
|
||||||
else {
|
|
||||||
acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
|
acpi_video_device_brightness_fops.write =
|
||||||
entry->proc_fops = &acpi_video_device_brightness_fops;
|
acpi_video_device_write_brightness;
|
||||||
entry->data = acpi_driver_data(device);
|
entry->proc_fops = &acpi_video_device_brightness_fops;
|
||||||
entry->owner = THIS_MODULE;
|
entry->data = acpi_driver_data(device);
|
||||||
}
|
entry->owner = THIS_MODULE;
|
||||||
|
|
||||||
/* 'EDID' [R] */
|
/* 'EDID' [R] */
|
||||||
entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
|
entry = create_proc_entry("EDID", S_IRUGO, device_dir);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_brightness;
|
||||||
else {
|
|
||||||
entry->proc_fops = &acpi_video_device_EDID_fops;
|
|
||||||
entry->data = acpi_driver_data(device);
|
|
||||||
entry->owner = THIS_MODULE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
entry->proc_fops = &acpi_video_device_EDID_fops;
|
||||||
|
entry->data = acpi_driver_data(device);
|
||||||
|
entry->owner = THIS_MODULE;
|
||||||
|
|
||||||
|
acpi_device_dir(device) = device_dir;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_remove_brightness:
|
||||||
|
remove_proc_entry("brightness", device_dir);
|
||||||
|
err_remove_state:
|
||||||
|
remove_proc_entry("state", device_dir);
|
||||||
|
err_remove_info:
|
||||||
|
remove_proc_entry("info", device_dir);
|
||||||
|
err_remove_dir:
|
||||||
|
remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int acpi_video_device_remove_fs(struct acpi_device *device)
|
static int acpi_video_device_remove_fs(struct acpi_device *device)
|
||||||
{
|
{
|
||||||
struct acpi_video_device *vid_dev;
|
struct acpi_video_device *vid_dev;
|
||||||
|
struct proc_dir_entry *device_dir;
|
||||||
|
|
||||||
vid_dev = acpi_driver_data(device);
|
vid_dev = acpi_driver_data(device);
|
||||||
if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
|
if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (acpi_device_dir(device)) {
|
device_dir = acpi_device_dir(device);
|
||||||
remove_proc_entry("info", acpi_device_dir(device));
|
if (device_dir) {
|
||||||
remove_proc_entry("state", acpi_device_dir(device));
|
remove_proc_entry("info", device_dir);
|
||||||
remove_proc_entry("brightness", acpi_device_dir(device));
|
remove_proc_entry("state", device_dir);
|
||||||
remove_proc_entry("EDID", acpi_device_dir(device));
|
remove_proc_entry("brightness", device_dir);
|
||||||
|
remove_proc_entry("EDID", device_dir);
|
||||||
remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
|
remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
|
||||||
acpi_device_dir(device) = NULL;
|
acpi_device_dir(device) = NULL;
|
||||||
}
|
}
|
||||||
@ -1335,94 +1338,91 @@ acpi_video_bus_write_DOS(struct file *file,
|
|||||||
|
|
||||||
static int acpi_video_bus_add_fs(struct acpi_device *device)
|
static int acpi_video_bus_add_fs(struct acpi_device *device)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *entry = NULL;
|
struct acpi_video_bus *video = acpi_driver_data(device);
|
||||||
struct acpi_video_bus *video;
|
struct proc_dir_entry *device_dir;
|
||||||
|
struct proc_dir_entry *entry;
|
||||||
|
|
||||||
|
device_dir = proc_mkdir(acpi_device_bid(device), acpi_video_dir);
|
||||||
|
if (!device_dir)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
video = acpi_driver_data(device);
|
device_dir->owner = THIS_MODULE;
|
||||||
|
|
||||||
if (!acpi_device_dir(device)) {
|
|
||||||
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
|
|
||||||
acpi_video_dir);
|
|
||||||
if (!acpi_device_dir(device))
|
|
||||||
return -ENODEV;
|
|
||||||
video->dir = acpi_device_dir(device);
|
|
||||||
acpi_device_dir(device)->owner = THIS_MODULE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 'info' [R] */
|
/* 'info' [R] */
|
||||||
entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
|
entry = create_proc_entry("info", S_IRUGO, device_dir);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_dir;
|
||||||
else {
|
|
||||||
entry->proc_fops = &acpi_video_bus_info_fops;
|
entry->proc_fops = &acpi_video_bus_info_fops;
|
||||||
entry->data = acpi_driver_data(device);
|
entry->data = acpi_driver_data(device);
|
||||||
entry->owner = THIS_MODULE;
|
entry->owner = THIS_MODULE;
|
||||||
}
|
|
||||||
|
|
||||||
/* 'ROM' [R] */
|
/* 'ROM' [R] */
|
||||||
entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
|
entry = create_proc_entry("ROM", S_IRUGO, device_dir);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_info;
|
||||||
else {
|
|
||||||
entry->proc_fops = &acpi_video_bus_ROM_fops;
|
entry->proc_fops = &acpi_video_bus_ROM_fops;
|
||||||
entry->data = acpi_driver_data(device);
|
entry->data = acpi_driver_data(device);
|
||||||
entry->owner = THIS_MODULE;
|
entry->owner = THIS_MODULE;
|
||||||
}
|
|
||||||
|
|
||||||
/* 'POST_info' [R] */
|
/* 'POST_info' [R] */
|
||||||
entry =
|
entry = create_proc_entry("POST_info", S_IRUGO, device_dir);
|
||||||
create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_rom;
|
||||||
else {
|
|
||||||
entry->proc_fops = &acpi_video_bus_POST_info_fops;
|
entry->proc_fops = &acpi_video_bus_POST_info_fops;
|
||||||
entry->data = acpi_driver_data(device);
|
entry->data = acpi_driver_data(device);
|
||||||
entry->owner = THIS_MODULE;
|
entry->owner = THIS_MODULE;
|
||||||
}
|
|
||||||
|
|
||||||
/* 'POST' [R/W] */
|
/* 'POST' [R/W] */
|
||||||
entry =
|
entry = create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
|
||||||
create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
|
device_dir);
|
||||||
acpi_device_dir(device));
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_post_info;
|
||||||
else {
|
|
||||||
acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
|
acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
|
||||||
entry->proc_fops = &acpi_video_bus_POST_fops;
|
entry->proc_fops = &acpi_video_bus_POST_fops;
|
||||||
entry->data = acpi_driver_data(device);
|
entry->data = acpi_driver_data(device);
|
||||||
entry->owner = THIS_MODULE;
|
entry->owner = THIS_MODULE;
|
||||||
}
|
|
||||||
|
|
||||||
/* 'DOS' [R/W] */
|
/* 'DOS' [R/W] */
|
||||||
entry =
|
entry = create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
|
||||||
create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
|
device_dir);
|
||||||
acpi_device_dir(device));
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENODEV;
|
goto err_remove_post;
|
||||||
else {
|
|
||||||
acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
|
|
||||||
entry->proc_fops = &acpi_video_bus_DOS_fops;
|
|
||||||
entry->data = acpi_driver_data(device);
|
|
||||||
entry->owner = THIS_MODULE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
|
||||||
|
entry->proc_fops = &acpi_video_bus_DOS_fops;
|
||||||
|
entry->data = acpi_driver_data(device);
|
||||||
|
entry->owner = THIS_MODULE;
|
||||||
|
|
||||||
|
video->dir = acpi_device_dir(device) = device_dir;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_remove_post:
|
||||||
|
remove_proc_entry("POST", device_dir);
|
||||||
|
err_remove_post_info:
|
||||||
|
remove_proc_entry("POST_info", device_dir);
|
||||||
|
err_remove_rom:
|
||||||
|
remove_proc_entry("ROM", device_dir);
|
||||||
|
err_remove_info:
|
||||||
|
remove_proc_entry("info", device_dir);
|
||||||
|
err_remove_dir:
|
||||||
|
remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int acpi_video_bus_remove_fs(struct acpi_device *device)
|
static int acpi_video_bus_remove_fs(struct acpi_device *device)
|
||||||
{
|
{
|
||||||
struct acpi_video_bus *video;
|
struct proc_dir_entry *device_dir = acpi_device_dir(device);
|
||||||
|
|
||||||
|
if (device_dir) {
|
||||||
video = acpi_driver_data(device);
|
remove_proc_entry("info", device_dir);
|
||||||
|
remove_proc_entry("ROM", device_dir);
|
||||||
if (acpi_device_dir(device)) {
|
remove_proc_entry("POST_info", device_dir);
|
||||||
remove_proc_entry("info", acpi_device_dir(device));
|
remove_proc_entry("POST", device_dir);
|
||||||
remove_proc_entry("ROM", acpi_device_dir(device));
|
remove_proc_entry("DOS", device_dir);
|
||||||
remove_proc_entry("POST_info", acpi_device_dir(device));
|
|
||||||
remove_proc_entry("POST", acpi_device_dir(device));
|
|
||||||
remove_proc_entry("DOS", acpi_device_dir(device));
|
|
||||||
remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
|
remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
|
||||||
acpi_device_dir(device) = NULL;
|
acpi_device_dir(device) = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user