All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/i915/opregion: fix leaking fw on error path
@ 2019-11-08  0:35 ` Lucas De Marchi
  0 siblings, 0 replies; 44+ messages in thread
From: Lucas De Marchi @ 2019-11-08  0:35 UTC (permalink / raw)
  To: intel-gfx

Convert the code to return-early style and fix missing calls
to release_firmware() if vbt is not valid.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/i915/display/intel_opregion.c | 28 +++++++++++--------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c
index 969ade623691..9738511147b1 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -872,23 +872,29 @@ static int intel_load_vbt_firmware(struct drm_i915_private *dev_priv)
 		return ret;
 	}
 
-	if (intel_bios_is_valid_vbt(fw->data, fw->size)) {
-		opregion->vbt_firmware = kmemdup(fw->data, fw->size, GFP_KERNEL);
-		if (opregion->vbt_firmware) {
-			DRM_DEBUG_KMS("Found valid VBT firmware \"%s\"\n", name);
-			opregion->vbt = opregion->vbt_firmware;
-			opregion->vbt_size = fw->size;
-			ret = 0;
-		} else {
-			ret = -ENOMEM;
-		}
-	} else {
+	if (!intel_bios_is_valid_vbt(fw->data, fw->size)) {
 		DRM_DEBUG_KMS("Invalid VBT firmware \"%s\"\n", name);
 		ret = -EINVAL;
+		goto err_release_fw;
+	}
+
+	opregion->vbt_firmware = kmemdup(fw->data, fw->size, GFP_KERNEL);
+	if (!opregion->vbt_firmware) {
+		ret = -ENOMEM;
+		goto err_release_fw;
 	}
 
+	opregion->vbt = opregion->vbt_firmware;
+	opregion->vbt_size = fw->size;
+
+	DRM_DEBUG_KMS("Found valid VBT firmware \"%s\"\n", name);
+
 	release_firmware(fw);
 
+	return 0;
+
+err_release_fw:
+	release_firmware(fw);
 	return ret;
 }
 
-- 
2.23.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2019-11-11 11:10 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08  0:35 [PATCH 1/4] drm/i915/opregion: fix leaking fw on error path Lucas De Marchi
2019-11-08  0:35 ` [Intel-gfx] " Lucas De Marchi
2019-11-08  0:36 ` [PATCH 2/4] drm/i915/bios: rename bios to oprom when mapping pci rom Lucas De Marchi
2019-11-08  0:36   ` [Intel-gfx] " Lucas De Marchi
2019-11-08 10:01   ` Jani Nikula
2019-11-08 10:01     ` [Intel-gfx] " Jani Nikula
2019-11-08  0:36 ` [PATCH 3/4] drm/i915/bios: make sure to check vbt size Lucas De Marchi
2019-11-08  0:36   ` [Intel-gfx] " Lucas De Marchi
2019-11-08 10:08   ` Jani Nikula
2019-11-08 10:08     ` [Intel-gfx] " Jani Nikula
2019-11-08 17:41     ` Lucas De Marchi
2019-11-08 17:41       ` [Intel-gfx] " Lucas De Marchi
2019-11-08  0:36 ` [PATCH 4/4] drm/i915/bios: do not discard address space Lucas De Marchi
2019-11-08  0:36   ` [Intel-gfx] " Lucas De Marchi
2019-11-08 11:14   ` Jani Nikula
2019-11-08 11:14     ` [Intel-gfx] " Jani Nikula
2019-11-08 18:18     ` Lucas De Marchi
2019-11-08 18:18       ` [Intel-gfx] " Lucas De Marchi
2019-11-08 19:19       ` Ville Syrjälä
2019-11-08 19:19         ` [Intel-gfx] " Ville Syrjälä
2019-11-08 20:14         ` Lucas De Marchi
2019-11-08 20:14           ` [Intel-gfx] " Lucas De Marchi
2019-11-08 21:02           ` Ville Syrjälä
2019-11-08 21:02             ` [Intel-gfx] " Ville Syrjälä
2019-11-08 21:09             ` Lucas De Marchi
2019-11-08 21:09               ` [Intel-gfx] " Lucas De Marchi
2019-11-11 11:10       ` Jani Nikula
2019-11-11 11:10         ` [Intel-gfx] " Jani Nikula
2019-11-10 16:57   ` kbuild test robot
2019-11-10 16:57     ` [Intel-gfx] " kbuild test robot
2019-11-10 16:57     ` kbuild test robot
2019-11-10 16:57   ` [RFC PATCH] drm/i915/bios: find_vbt() can be static kbuild test robot
2019-11-10 16:57     ` kbuild test robot
2019-11-10 16:57     ` [Intel-gfx] " kbuild test robot
2019-11-08  1:53 ` ✗ Fi.CI.SPARSE: warning for series starting with [1/4] drm/i915/opregion: fix leaking fw on error path Patchwork
2019-11-08  1:53   ` [Intel-gfx] " Patchwork
2019-11-08  2:18 ` ✓ Fi.CI.BAT: success " Patchwork
2019-11-08  2:18   ` [Intel-gfx] " Patchwork
2019-11-08  9:16 ` [PATCH 1/4] " Jani Nikula
2019-11-08  9:16   ` [Intel-gfx] " Jani Nikula
2019-11-08 17:34   ` Lucas De Marchi
2019-11-08 17:34     ` [Intel-gfx] " Lucas De Marchi
2019-11-09 13:23 ` ✓ Fi.CI.IGT: success for series starting with [1/4] " Patchwork
2019-11-09 13:23   ` [Intel-gfx] " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.