Skip to contentSkip to conversation

sony-laptop: handle allocation failures

PATCH In review Dan Carpenter 2 participants 2 messages Feb 26, 2011 – Feb 27, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 sony-laptop: handle allocation failures

Return -ENOMEM if kzalloc() fails. The callers already handle error returns.

drivers/platform/x86/sony-laptop.c +4 -0
index d0d0522..0db9049 100644
@@ -768,6 +768,8 @@ static int sony_nc_handles_setup(struct platform_device *pd)
 	int result;
 
 	handles = kzalloc(sizeof(*handles), GFP_KERNEL);
+	if (!handles)
+		return -ENOMEM;
 
 	sysfs_attr_init(&handles->devattr.attr);
 	handles->devattr.attr.name = "handles";
@@ -1458,6 +1460,8 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd)
 		return 0;
 
 	kbdbl_handle = kzalloc(sizeof(*kbdbl_handle), GFP_KERNEL);
+	if (!kbdbl_handle)
+		return -ENOMEM;
 
 	sysfs_attr_init(&kbdbl_handle->mode_attr.attr);
 	kbdbl_handle->mode_attr.attr.name = "kbd_backlight";
maintainer Acked-by on v1 3/3
#1 lore raw
Quoted 4 lines · Dan Carpenter

Return -ENOMEM if kzalloc() fails. The callers already handle error returns.

Quoted 22 lines
drivers/platform/x86/sony-laptop.c +4 -0
index d0d0522..0db9049 100644
@@ -768,6 +768,8 @@ static int sony_nc_handles_setup(struct platform_device *pd)
 	int result;
 
 	handles = kzalloc(sizeof(*handles), GFP_KERNEL);
+	if (!handles)
+		return -ENOMEM;
 
 	sysfs_attr_init(&handles->devattr.attr);
 	handles->devattr.attr.name = "handles";
@@ -1458,6 +1460,8 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd)
 		return 0;
 
 	kbdbl_handle = kzalloc(sizeof(*kbdbl_handle), GFP_KERNEL);
+	if (!kbdbl_handle)
+		return -ENOMEM;
 
 	sysfs_attr_init(&kbdbl_handle->mode_attr.attr);
 	kbdbl_handle->mode_attr.attr.name = "kbd_backlight";
Signature · 2 lines
mattia
:wq!