Skip to contentSkip to conversation

drm/radeon: fix uninitialized bool variable

PATCH In review Zhiwei Yang 3 participants 3 messages Sep 18, 2021 – Sep 20, 2021

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

PATCH 1/1 drm/radeon: fix uninitialized bool variable

The bool variable detected_hpd_without_ddc in struct radeon_connector is uninitialized when first used, that may cause unnecessary ddc ops. Make it as false when a new connector is alloced.

---
 drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_connectors.c +4 -0
index fe12d9d91d7a..c1987a66373f 100644
@@ -1866,6 +1866,7 @@ radeon_add_atom_connector(struct drm_device *dev,
 	bool shared_ddc = false;
 	bool is_dp_bridge = false;
 	bool has_aux = false;
+	bool detected_hpd_without_ddc = false;
 
 	if (connector_type == DRM_MODE_CONNECTOR_Unknown)
 		return;
@@ -1923,6 +1924,7 @@ radeon_add_atom_connector(struct drm_device *dev,
 	radeon_connector->shared_ddc = shared_ddc;
 	radeon_connector->connector_object_id = connector_object_id;
 	radeon_connector->hpd = *hpd;
+	radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
 
 	radeon_connector->router = *router;
 	if (router->ddc_valid || router->cd_valid) {
@@ -2384,6 +2386,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
 	struct radeon_connector *radeon_connector;
 	struct i2c_adapter *ddc = NULL;
 	uint32_t subpixel_order = SubPixelNone;
+	bool detected_hpd_without_ddc = false;
 
 	if (connector_type == DRM_MODE_CONNECTOR_Unknown)
 		return;
@@ -2414,6 +2417,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
 	radeon_connector->devices = supported_device;
 	radeon_connector->connector_object_id = connector_object_id;
 	radeon_connector->hpd = *hpd;
+	radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
 
 	switch (connector_type) {
 	case DRM_MODE_CONNECTOR_VGA:
Signature · 1 line
2.20.1
#1 lore raw

Am 18.09.21 um 11:41 schrieb Zhiwei Yang:

Quoted 14 lines

The bool variable detected_hpd_without_ddc in struct radeon_connector is uninitialized when first used, that may cause unnecessary ddc ops. Make it as false when a new connector is alloced.

---
  drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_connectors.c +0 -0
index fe12d9d91d7a..c1987a66373f 100644

drivers/gpu/drm/radeon/radeon_connectors.c radeon_add_atom_connector(struct drm_device *dev, · line 1869

Quoted 4 lines
drivers/gpu/drm/radeon/radeon_connectors.c +1 -0
@@ -1866,6 +1866,7 @@ radeon_add_atom_connector(struct drm_device *dev,
  	bool shared_ddc = false;
  	bool is_dp_bridge = false;
  	bool has_aux = false;
+	bool detected_hpd_without_ddc = false;

In general good catch, but I don't see the need for a local variable here.

Just initialize the member directly or even better change the allocation of the connector into a kzalloc().

Christian.

Quoted 27 lines
drivers/gpu/drm/radeon/radeon_connectors.c +3 -0
  	if (connector_type == DRM_MODE_CONNECTOR_Unknown)
  		return;
@@ -1923,6 +1924,7 @@ radeon_add_atom_connector(struct drm_device *dev,
  	radeon_connector->shared_ddc = shared_ddc;
  	radeon_connector->connector_object_id = connector_object_id;
  	radeon_connector->hpd = *hpd;
+	radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
 
  	radeon_connector->router = *router;
  	if (router->ddc_valid || router->cd_valid) {
@@ -2384,6 +2386,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
  	struct radeon_connector *radeon_connector;
  	struct i2c_adapter *ddc = NULL;
  	uint32_t subpixel_order = SubPixelNone;
+	bool detected_hpd_without_ddc = false;
 
  	if (connector_type == DRM_MODE_CONNECTOR_Unknown)
  		return;
@@ -2414,6 +2417,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
  	radeon_connector->devices = supported_device;
  	radeon_connector->connector_object_id = connector_object_id;
  	radeon_connector->hpd = *hpd;
+	radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
 
  	switch (connector_type) {
  	case DRM_MODE_CONNECTOR_VGA:
#2 lore raw
Quoted 25 lines · Christian König

Am 18.09.21 um 11:41 schrieb Zhiwei Yang:

Quoted 14 lines

The bool variable detected_hpd_without_ddc in struct radeon_connector is uninitialized when first used, that may cause unnecessary ddc ops. Make it as false when a new connector is alloced.

---
  drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_connectors.c +0 -0
index fe12d9d91d7a..c1987a66373f 100644

drivers/gpu/drm/radeon/radeon_connectors.c radeon_add_atom_connector(struct drm_device *dev, · line 1869

Quoted 4 lines
drivers/gpu/drm/radeon/radeon_connectors.c +1 -0
@@ -1866,6 +1866,7 @@ radeon_add_atom_connector(struct drm_device *dev,
      bool shared_ddc = false;
      bool is_dp_bridge = false;
      bool has_aux = false;
+     bool detected_hpd_without_ddc = false;

In general good catch, but I don't see the need for a local variable here.

Quoted 2 lines

Just initialize the member directly or even better change the allocation of the connector into a kzalloc().

This is already the case:

        radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL);

So I don't think this patch is necessary.

Alex

Quoted 31 lines

Christian.

Quoted 27 lines
drivers/gpu/drm/radeon/radeon_connectors.c +3 -0
      if (connector_type == DRM_MODE_CONNECTOR_Unknown)
              return;
@@ -1923,6 +1924,7 @@ radeon_add_atom_connector(struct drm_device *dev,
      radeon_connector->shared_ddc = shared_ddc;
      radeon_connector->connector_object_id = connector_object_id;
      radeon_connector->hpd = *hpd;
+     radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
 
      radeon_connector->router = *router;
      if (router->ddc_valid || router->cd_valid) {
@@ -2384,6 +2386,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
      struct radeon_connector *radeon_connector;
      struct i2c_adapter *ddc = NULL;
      uint32_t subpixel_order = SubPixelNone;
+     bool detected_hpd_without_ddc = false;
 
      if (connector_type == DRM_MODE_CONNECTOR_Unknown)
              return;
@@ -2414,6 +2417,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
      radeon_connector->devices = supported_device;
      radeon_connector->connector_object_id = connector_object_id;
      radeon_connector->hpd = *hpd;
+     radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
 
      switch (connector_type) {
      case DRM_MODE_CONNECTOR_VGA: