Skip to contentSkip to conversation

drm/i915: Fix plane init failure paths

PATCH Applied Matthew Auld 3 participants 4 messages Mar 21, 2016 – Apr 1, 2016

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

PATCH 1/1 drm/i915: Fix plane init failure paths

From: Ville Syrjälä <[email protected]>

Deal with errors from drm_universal_plane_init() in primary and cursor plane init paths (sprites were already covered). Also make the code neater by using goto for error handling.

v2: Rebased due to drm_universal_plane_init() 'name' parameter
v3: Another rebase due to s/""/NULL/
v4: Rebased on drm-nightly (Matthew Auld)
v5: Fix email address (Matthew Auld)

---
 drivers/gpu/drm/i915/intel_display.c | 64 ++++++++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_sprite.c  | 34 +++++++++++--------
 2 files changed, 60 insertions(+), 38 deletions(-)
drivers/gpu/drm/i915/intel_display.c +39 -25
index 74b0165..f3f6fd1 100644
@@ -13961,20 +13961,19 @@ const struct drm_plane_funcs intel_plane_funcs = {
 static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 						    int pipe)
 {
-	struct intel_plane *primary;
-	struct intel_plane_state *state;
+	struct intel_plane *primary = NULL;
+	struct intel_plane_state *state = NULL;
 	const uint32_t *intel_primary_formats;
 	unsigned int num_formats;
+	int ret;
 
 	primary = kzalloc(sizeof(*primary), GFP_KERNEL);
-	if (primary == NULL)
-		return NULL;
+	if (!primary)
+		goto fail;
 
 	state = intel_create_plane_state(&primary->base);
-	if (!state) {
-		kfree(primary);
-		return NULL;
-	}
+	if (!state)
+		goto fail;
 	primary->base.state = &state->base;
 
 	primary->can_scale = false;
@@ -14016,10 +14015,12 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 		primary->disable_plane = i9xx_disable_primary_plane;
 	}
 
-	drm_universal_plane_init(dev, &primary->base, 0,
-				 &intel_plane_funcs,
-				 intel_primary_formats, num_formats,
-				 DRM_PLANE_TYPE_PRIMARY, NULL);
+	ret = drm_universal_plane_init(dev, &primary->base, 0,
+				       &intel_plane_funcs,
+				       intel_primary_formats, num_formats,
+				       DRM_PLANE_TYPE_PRIMARY, NULL);
+	if (ret)
+		goto fail;
 
 	if (INTEL_INFO(dev)->gen >= 4)
 		intel_create_rotation_property(dev, primary);
@@ -14027,6 +14028,12 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 	drm_plane_helper_add(&primary->base, &intel_plane_helper_funcs);
 
 	return &primary->base;
+
+fail:
+	kfree(state);
+	kfree(primary);
+
+	return NULL;
 }
 
 void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *plane)
@@ -14143,18 +14150,17 @@ intel_update_cursor_plane(struct drm_plane *plane,
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 						   int pipe)
 {
-	struct intel_plane *cursor;
-	struct intel_plane_state *state;
+	struct intel_plane *cursor = NULL;
+	struct intel_plane_state *state = NULL;
+	int ret;
 
 	cursor = kzalloc(sizeof(*cursor), GFP_KERNEL);
-	if (cursor == NULL)
-		return NULL;
+	if (!cursor)
+		goto fail;
 
 	state = intel_create_plane_state(&cursor->base);
-	if (!state) {
-		kfree(cursor);
-		return NULL;
-	}
+	if (!state)
+		goto fail;
 	cursor->base.state = &state->base;
 
 	cursor->can_scale = false;
@@ -14166,11 +14172,13 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	cursor->update_plane = intel_update_cursor_plane;
 	cursor->disable_plane = intel_disable_cursor_plane;
 
-	drm_universal_plane_init(dev, &cursor->base, 0,
-				 &intel_plane_funcs,
-				 intel_cursor_formats,
-				 ARRAY_SIZE(intel_cursor_formats),
-				 DRM_PLANE_TYPE_CURSOR, NULL);
+	ret = drm_universal_plane_init(dev, &cursor->base, 0,
+				       &intel_plane_funcs,
+				       intel_cursor_formats,
+				       ARRAY_SIZE(intel_cursor_formats),
+				       DRM_PLANE_TYPE_CURSOR, NULL);
+	if (ret)
+		goto fail;
 
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (!dev->mode_config.rotation_property)
@@ -14190,6 +14198,12 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	drm_plane_helper_add(&cursor->base, &intel_plane_helper_funcs);
 
 	return &cursor->base;
+
+fail:
+	kfree(state);
+	kfree(cursor);
+
+	return NULL;
 }
 
 static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_crtc,
drivers/gpu/drm/i915/intel_sprite.c +21 -13
index 8821533..0f3e230 100644
@@ -1025,8 +1025,8 @@ static uint32_t skl_plane_formats[] = {
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
-	struct intel_plane *intel_plane;
-	struct intel_plane_state *state;
+	struct intel_plane *intel_plane = NULL;
+	struct intel_plane_state *state = NULL;
 	unsigned long possible_crtcs;
 	const uint32_t *plane_formats;
 	int num_plane_formats;
@@ -1036,13 +1036,15 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 		return -ENODEV;
 
 	intel_plane = kzalloc(sizeof(*intel_plane), GFP_KERNEL);
-	if (!intel_plane)
-		return -ENOMEM;
+	if (!intel_plane) {
+		ret = -ENOMEM;
+		goto fail;
+	}
 
 	state = intel_create_plane_state(&intel_plane->base);
 	if (!state) {
-		kfree(intel_plane);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto fail;
 	}
 	intel_plane->base.state = &state->base;
 
@@ -1097,28 +1099,34 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 		num_plane_formats = ARRAY_SIZE(skl_plane_formats);
 		break;
 	default:
-		kfree(intel_plane);
-		return -ENODEV;
+		MISSING_CASE(INTEL_INFO(dev)->gen);
+		ret = -ENODEV;
+		goto fail;
 	}
 
 	intel_plane->pipe = pipe;
 	intel_plane->plane = plane;
 	intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane);
 	intel_plane->check_plane = intel_check_sprite_plane;
+
 	possible_crtcs = (1 << pipe);
+
 	ret = drm_universal_plane_init(dev, &intel_plane->base, possible_crtcs,
 				       &intel_plane_funcs,
 				       plane_formats, num_plane_formats,
 				       DRM_PLANE_TYPE_OVERLAY, NULL);
-	if (ret) {
-		kfree(intel_plane);
-		goto out;
-	}
+	if (ret)
+		goto fail;
 
 	intel_create_rotation_property(dev, intel_plane);
 
 	drm_plane_helper_add(&intel_plane->base, &intel_plane_helper_funcs);
 
-out:
+	return 0;
+
+fail:
+	kfree(state);
+	kfree(intel_plane);
+
 	return ret;
 }
Signature · 6 lines
2.4.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ Fi.CI.BAT: warning for drm/i915: Fix plane init failure paths (rev2)

== Series Details ==

== Series Details ==

Series: drm/i915: Fix plane init failure paths (rev2)
URL : https://patchwork.freedesktop.org/series/4708/
State : warning

== Summary ==

Series 4708v2 drm/i915: Fix plane init failure paths
http://patchwork.freedesktop.org/api/1.0/series/4708/revisions/2/mbox/

Test gem_exec_suspend:

        Subgroup basic-s3:
                pass       -> DMESG-WARN (bsw-nuc-2)
Test kms_flip:
        Subgroup basic-flip-vs-dpms:
                dmesg-warn -> PASS       (ilk-hp8440p) UNSTABLE
        Subgroup basic-plain-flip:
                dmesg-warn -> PASS       (bdw-ultra)
Test kms_pipe_crc_basic:
        Subgroup read-crc-pipe-a:
                pass       -> SKIP       (hsw-brixbox)
        Subgroup suspend-read-crc-pipe-b:
                pass       -> DMESG-WARN (snb-x220t)
        Subgroup suspend-read-crc-pipe-c:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                pass       -> DMESG-WARN (snb-dellxps)
        Subgroup basic-rte:
                dmesg-warn -> PASS       (snb-x220t)
bdw-nuci7        total:192  pass:180  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultra        total:192  pass:171  dwarn:0   dfail:0   fail:0   skip:21 
bsw-nuc-2        total:192  pass:154  dwarn:1   dfail:0   fail:0   skip:37 
hsw-brixbox      total:192  pass:169  dwarn:0   dfail:0   fail:0   skip:23 
ilk-hp8440p      total:192  pass:129  dwarn:0   dfail:0   fail:0   skip:63 
ivb-t430s        total:192  pass:167  dwarn:0   dfail:0   fail:0   skip:25 
skl-i5k-2        total:192  pass:169  dwarn:0   dfail:0   fail:0   skip:23 
skl-i7k-2        total:192  pass:169  dwarn:0   dfail:0   fail:0   skip:23 
snb-dellxps      total:192  pass:156  dwarn:2   dfail:0   fail:0   skip:34 
snb-x220t        total:192  pass:157  dwarn:1   dfail:0   fail:1   skip:33 

Results at /archive/results/CI_IGT_test/Patchwork_1665/

4b39223f6e3bef4dfa678f7239dcd87c38e20e96 drm-intel-nightly: 2016y-03m-21d-18h-43m-18s UTC integration manifest 7a7ff14de1ec3bb03359172a4ee99ce6786a7203 drm/i915: Fix plane init failure paths

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

Re: ✗ Fi.CI.BAT: warning for drm/i915: Fix plane init failure paths (rev2)

Quoted 6 lines · Patchwork

== Series Details ==

Series: drm/i915: Fix plane init failure paths (rev2)
URL : https://patchwork.freedesktop.org/series/4708/
State : warning

Quoted 8 lines

== Summary ==

Series 4708v2 drm/i915: Fix plane init failure paths
http://patchwork.freedesktop.org/api/1.0/series/4708/revisions/2/mbox/

Test gem_exec_suspend:

        Subgroup basic-s3:
                pass       -> DMESG-WARN (bsw-nuc-2)

already fixed lockdep

[  175.716877] ======================================================
[  175.716878] [ INFO: possible circular locking dependency detected ]
[  175.716882] 4.5.0-gfxbench+ #1 Not tainted
[  175.716884] -------------------------------------------------------
[  175.716886] rtcwake/5979 is trying to acquire lock:
[  175.716904]  (s_active#6){++++.+}, at: [<ffffffff81250740>] kernfs_remove_by_name_ns+0x40/0xa0
[  175.716905] 
but task is already holding lock:
[  175.716915]  (cpu_hotplug.lock){+.+.+.}, at: [<ffffffff81078f5d>] cpu_hotplug_begin+0x6d/0xc0
[  175.716916] 

which lock already depends on the new lock.

Quoted 8 lines

Test kms_flip:

        Subgroup basic-flip-vs-dpms:
                dmesg-warn -> PASS       (ilk-hp8440p) UNSTABLE
        Subgroup basic-plain-flip:
                dmesg-warn -> PASS       (bdw-ultra)
Test kms_pipe_crc_basic:
        Subgroup read-crc-pipe-a:
                pass       -> SKIP       (hsw-brixbox)

modes disappeared?
(kms_pipe_crc_basic:6548) igt-kms-WARNING: connector 37 has no modes

[  395.210191] [drm:intel_get_hpd_pins] hotplug event received, stat 0x00200000, dig 0x00101012, pins 0x00000020
[  395.210195] [drm:intel_hpd_irq_storm_detect] Received HPD interrupt on PIN 5 - cnt: 0
[  395.210236] [drm:i915_hotplug_work_func] running encoder hotplug functions
[  395.210239] [drm:i915_hotplug_work_func] Connector HDMI-A-1 (pin 5) received hotplug event.
[  395.210241] [drm:intel_hdmi_detect] [CONNECTOR:37:HDMI-A-1]
[  395.297324] [drm:intel_hdmi_detect] Live status not up!
[  395.297337] [drm:intel_hpd_irq_event] [CONNECTOR:37:HDMI-A-1] status updated from connected to disconnected
[  395.297391] [drm:drm_fb_helper_hotplug_event] 
[  395.297393] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:37:HDMI-A-1]
[  395.297395] [drm:intel_hdmi_detect] [CONNECTOR:37:HDMI-A-1]
[  395.308858] kms_pipe_crc_basic: executing
[  395.308998] [drm:i915_gem_open] 
[  395.310786] [drm:i915_gem_open] 
[  395.310845] [drm:i915_gem_open] 
[  395.385309] [drm:intel_hdmi_detect] Live status not up!
[  395.385313] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:37:HDMI-A-1] disconnected
[  395.385439] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:42:DP-1]
[  395.385441] [drm:intel_dp_detect] [CONNECTOR:42:DP-1]
[  395.385446] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:42:DP-1] disconnected
[  395.385447] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:46:HDMI-A-2]
[  395.385448] [drm:intel_hdmi_detect] [CONNECTOR:46:HDMI-A-2]
[  395.407916] [drm:intel_get_hpd_pins] hotplug event received, stat 0x00200000, dig 0x00101012, pins 0x00000020
[  395.407919] [drm:intel_hpd_irq_storm_detect] Received HPD interrupt on PIN 5 - cnt: 1
[  395.473312] [drm:intel_hdmi_detect] Live status not up!
[  395.473315] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:46:HDMI-A-2] disconnected
...
[  395.500701] [drm:i915_hotplug_work_func] running encoder hotplug functions
[  395.500702] [drm:i915_hotplug_work_func] Connector HDMI-A-1 (pin 5) received hotplug event.
[  395.500704] [drm:intel_hdmi_detect] [CONNECTOR:37:HDMI-A-1]
[  395.500705] [drm:intel_power_well_enable] enabling always-on
[  395.527639] [drm:drm_detect_monitor_audio] Monitor has basic audio support
[  395.527642] [drm:intel_power_well_disable] disabling always-on
[  395.527644] [drm:intel_hpd_irq_event] [CONNECTOR:37:HDMI-A-1] status updated from disconnected to connected
...
[  395.530575] kms_pipe_crc_basic: starting subtest read-crc-pipe-A
[  395.530650] kms_pipe_crc_basic: exiting, ret=0
[  395.536518] [drm:drm_fb_helper_hotplug_event] 
[  395.536520] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:37:HDMI-A-1]
[  395.536521] [drm:intel_hdmi_detect] [CONNECTOR:37:HDMI-A-1]
[  395.536523] [drm:intel_power_well_enable] enabling always-on
[  395.563409] [drm:drm_detect_monitor_audio] Monitor has basic audio support
[  395.563412] [drm:intel_power_well_disable] disabling always-on
[  395.563586] [drm:drm_edid_to_eld] ELD monitor G246HYL
[  395.563588] [drm:parse_hdmi_vsdb] HDMI: DVI dual 0, max TMDS clock 0, latency present 0 0, video latency 0 0, audio latency 0 0
[  395.563589] [drm:drm_edid_to_eld] ELD size 32, SAD count 1
[  395.563638] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:37:HDMI-A-1] probed modes :

...

So it looks like there was a disconnect+reconnect happening in parallel for whatever reason and we just didn't manage to populate the modelist by the time this particular subtest ran. No idea what caused the dip on the hpd line.

Quoted 2 lines
        Subgroup suspend-read-crc-pipe-b:
                pass       -> DMESG-WARN (snb-x220t)

already fixed

[  448.693328] WARNING: CPU: 2 PID: 6423 at drivers/gpu/drm/i915/intel_drv.h:1482 gen6_write32+0x22e/0x290 [i915]()
[  448.693331] Device suspended during HW access
[  448.693466]  [<ffffffffa036dbb8>] _ilk_disable_lp_wm+0x98/0xd0 [i915]
[  448.693492]  [<ffffffffa037322d>] ilk_program_watermarks+0x4bd/0x980 [i915]
Quoted 5 lines
        Subgroup suspend-read-crc-pipe-c:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                pass       -> DMESG-WARN (snb-dellxps)

same

Quoted 23 lines
        Subgroup basic-rte:
                dmesg-warn -> PASS       (snb-x220t)
bdw-nuci7        total:192  pass:180  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultra        total:192  pass:171  dwarn:0   dfail:0   fail:0   skip:21 
bsw-nuc-2        total:192  pass:154  dwarn:1   dfail:0   fail:0   skip:37 
hsw-brixbox      total:192  pass:169  dwarn:0   dfail:0   fail:0   skip:23 
ilk-hp8440p      total:192  pass:129  dwarn:0   dfail:0   fail:0   skip:63 
ivb-t430s        total:192  pass:167  dwarn:0   dfail:0   fail:0   skip:25 
skl-i5k-2        total:192  pass:169  dwarn:0   dfail:0   fail:0   skip:23 
skl-i7k-2        total:192  pass:169  dwarn:0   dfail:0   fail:0   skip:23 
snb-dellxps      total:192  pass:156  dwarn:2   dfail:0   fail:0   skip:34 
snb-x220t        total:192  pass:157  dwarn:1   dfail:0   fail:1   skip:33 

Results at /archive/results/CI_IGT_test/Patchwork_1665/

4b39223f6e3bef4dfa678f7239dcd87c38e20e96 drm-intel-nightly: 2016y-03m-21d-18h-43m-18s UTC integration manifest 7a7ff14de1ec3bb03359172a4ee99ce6786a7203 drm/i915: Fix plane init failure paths

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
In reply to Matthew Auld
Quoted 6 lines · Matthew Auld

From: Ville Syrjälä <[email protected]>

Deal with errors from drm_universal_plane_init() in primary and cursor plane init paths (sprites were already covered). Also make the code neater by using goto for error handling.

Quoted 7 lines

v2: Rebased due to drm_universal_plane_init() 'name' parameter
v3: Another rebase due to s/""/NULL/
v4: Rebased on drm-nightly (Matthew Auld)
v5: Fix email address (Matthew Auld)

Pushed to dinq. Thanks for the review.

Quoted 204 lines
---
 drivers/gpu/drm/i915/intel_display.c | 64 ++++++++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_sprite.c  | 34 +++++++++++--------
 2 files changed, 60 insertions(+), 38 deletions(-)
drivers/gpu/drm/i915/intel_display.c +39 -25
index 74b0165..f3f6fd1 100644
@@ -13961,20 +13961,19 @@ const struct drm_plane_funcs intel_plane_funcs = {
 static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 						    int pipe)
 {
-	struct intel_plane *primary;
-	struct intel_plane_state *state;
+	struct intel_plane *primary = NULL;
+	struct intel_plane_state *state = NULL;
 	const uint32_t *intel_primary_formats;
 	unsigned int num_formats;
+	int ret;
 
 	primary = kzalloc(sizeof(*primary), GFP_KERNEL);
-	if (primary == NULL)
-		return NULL;
+	if (!primary)
+		goto fail;
 
 	state = intel_create_plane_state(&primary->base);
-	if (!state) {
-		kfree(primary);
-		return NULL;
-	}
+	if (!state)
+		goto fail;
 	primary->base.state = &state->base;
 
 	primary->can_scale = false;
@@ -14016,10 +14015,12 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 		primary->disable_plane = i9xx_disable_primary_plane;
 	}
 
-	drm_universal_plane_init(dev, &primary->base, 0,
-				 &intel_plane_funcs,
-				 intel_primary_formats, num_formats,
-				 DRM_PLANE_TYPE_PRIMARY, NULL);
+	ret = drm_universal_plane_init(dev, &primary->base, 0,
+				       &intel_plane_funcs,
+				       intel_primary_formats, num_formats,
+				       DRM_PLANE_TYPE_PRIMARY, NULL);
+	if (ret)
+		goto fail;
 
 	if (INTEL_INFO(dev)->gen >= 4)
 		intel_create_rotation_property(dev, primary);
@@ -14027,6 +14028,12 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 	drm_plane_helper_add(&primary->base, &intel_plane_helper_funcs);
 
 	return &primary->base;
+
+fail:
+	kfree(state);
+	kfree(primary);
+
+	return NULL;
 }
 
 void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *plane)
@@ -14143,18 +14150,17 @@ intel_update_cursor_plane(struct drm_plane *plane,
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 						   int pipe)
 {
-	struct intel_plane *cursor;
-	struct intel_plane_state *state;
+	struct intel_plane *cursor = NULL;
+	struct intel_plane_state *state = NULL;
+	int ret;
 
 	cursor = kzalloc(sizeof(*cursor), GFP_KERNEL);
-	if (cursor == NULL)
-		return NULL;
+	if (!cursor)
+		goto fail;
 
 	state = intel_create_plane_state(&cursor->base);
-	if (!state) {
-		kfree(cursor);
-		return NULL;
-	}
+	if (!state)
+		goto fail;
 	cursor->base.state = &state->base;
 
 	cursor->can_scale = false;
@@ -14166,11 +14172,13 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	cursor->update_plane = intel_update_cursor_plane;
 	cursor->disable_plane = intel_disable_cursor_plane;
 
-	drm_universal_plane_init(dev, &cursor->base, 0,
-				 &intel_plane_funcs,
-				 intel_cursor_formats,
-				 ARRAY_SIZE(intel_cursor_formats),
-				 DRM_PLANE_TYPE_CURSOR, NULL);
+	ret = drm_universal_plane_init(dev, &cursor->base, 0,
+				       &intel_plane_funcs,
+				       intel_cursor_formats,
+				       ARRAY_SIZE(intel_cursor_formats),
+				       DRM_PLANE_TYPE_CURSOR, NULL);
+	if (ret)
+		goto fail;
 
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (!dev->mode_config.rotation_property)
@@ -14190,6 +14198,12 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	drm_plane_helper_add(&cursor->base, &intel_plane_helper_funcs);
 
 	return &cursor->base;
+
+fail:
+	kfree(state);
+	kfree(cursor);
+
+	return NULL;
 }
 
 static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_crtc,
drivers/gpu/drm/i915/intel_sprite.c +21 -13
index 8821533..0f3e230 100644
@@ -1025,8 +1025,8 @@ static uint32_t skl_plane_formats[] = {
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
-	struct intel_plane *intel_plane;
-	struct intel_plane_state *state;
+	struct intel_plane *intel_plane = NULL;
+	struct intel_plane_state *state = NULL;
 	unsigned long possible_crtcs;
 	const uint32_t *plane_formats;
 	int num_plane_formats;
@@ -1036,13 +1036,15 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 		return -ENODEV;
 
 	intel_plane = kzalloc(sizeof(*intel_plane), GFP_KERNEL);
-	if (!intel_plane)
-		return -ENOMEM;
+	if (!intel_plane) {
+		ret = -ENOMEM;
+		goto fail;
+	}
 
 	state = intel_create_plane_state(&intel_plane->base);
 	if (!state) {
-		kfree(intel_plane);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto fail;
 	}
 	intel_plane->base.state = &state->base;
 
@@ -1097,28 +1099,34 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 		num_plane_formats = ARRAY_SIZE(skl_plane_formats);
 		break;
 	default:
-		kfree(intel_plane);
-		return -ENODEV;
+		MISSING_CASE(INTEL_INFO(dev)->gen);
+		ret = -ENODEV;
+		goto fail;
 	}
 
 	intel_plane->pipe = pipe;
 	intel_plane->plane = plane;
 	intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane);
 	intel_plane->check_plane = intel_check_sprite_plane;
+
 	possible_crtcs = (1 << pipe);
+
 	ret = drm_universal_plane_init(dev, &intel_plane->base, possible_crtcs,
 				       &intel_plane_funcs,
 				       plane_formats, num_plane_formats,
 				       DRM_PLANE_TYPE_OVERLAY, NULL);
-	if (ret) {
-		kfree(intel_plane);
-		goto out;
-	}
+	if (ret)
+		goto fail;
 
 	intel_create_rotation_property(dev, intel_plane);
 
 	drm_plane_helper_add(&intel_plane->base, &intel_plane_helper_funcs);
 
-out:
+	return 0;
+
+fail:
+	kfree(state);
+	kfree(intel_plane);
+
 	return ret;
 }
Signature · 1 line
2.4.3
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx