diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 33933b11..5236e1f9 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -130,6 +130,25 @@ int DebayerEGL::getShaderVariableLocations(void)
 			    << " tex_bayer_first_red " << textureUniformBayerFirstRed_
 			    << " proj_matrix " << textureUniformProjMatrix_
 			    << " tex_lsc " << textureUniformLsc_;
+
+	if (
+		attributeVertex_ == -1 ||
+		attributeTexture_ == -1 ||
+		textureUniformBayerDataIn_ == -1 ||
+		awbUniformDataIn_ == -1 ||
+		ccmUniformDataIn_ == -1 ||
+		blackLevelUniformDataIn_ == -1 ||
+		gammaUniformDataIn_ == -1 ||
+		contrastExpUniformDataIn_ == -1 ||
+		textureUniformStep_ == -1 ||
+		textureUniformSize_ == -1 ||
+		textureUniformStrideFactor_ == -1 ||
+		textureUniformBayerFirstRed_ == -1 ||
+		textureUniformProjMatrix_ == -1 ||
+		(lscEnabled_ && textureUniformLsc_ == -1)) {
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -274,7 +293,12 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm
 		return -ENODEV;
 	}
 
-	return getShaderVariableLocations();
+	if (getShaderVariableLocations() != 0) {
+		LOG(Debayer, Error) << "Find shader variables fail";
+		return -ENODEV;
+	}
+
+	return 0;
 }
 
 int DebayerEGL::configure(const StreamConfiguration &inputCfg,
