[bug report] drm/amd/display: Only register backlight device if embedded panel connected
Dan Carpenter
dan.carpenter at oracle.com
Tue Nov 27 10:40:48 UTC 2018
Hello Harry Wentland,
The patch 89fc8d4e95e7: "drm/amd/display: Only register backlight
device if embedded panel connected" from Mar 12, 2018, leads to the
following static checker warning:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:1785 amdgpu_dm_initialize_drm_device()
warn: 'i' is out of bounds '31' vs '11'
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c
1756 /* loops over all connectors on the board */
1757 for (i = 0; i < link_cnt; i++) {
^^^^^^^^
I believe the link_cnt is at most 12? Smatch has trouble figuring it
out.
1758 struct dc_link *link = NULL;
1759
1760 if (i > AMDGPU_DM_MAX_DISPLAY_INDEX) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is 32 so Smatch says that i can go up to 31.
1761 DRM_ERROR(
1762 "KMS: Cannot support more than %d display indexes\n",
1763 AMDGPU_DM_MAX_DISPLAY_INDEX);
1764 continue;
1765 }
1766
1767 aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL);
1768 if (!aconnector)
1769 goto fail;
1770
1771 aencoder = kzalloc(sizeof(*aencoder), GFP_KERNEL);
1772 if (!aencoder)
1773 goto fail;
1774
1775 if (amdgpu_dm_encoder_init(dm->ddev, aencoder, i)) {
1776 DRM_ERROR("KMS: Failed to initialize encoder\n");
1777 goto fail;
1778 }
1779
1780 if (amdgpu_dm_connector_init(dm, aconnector, i, aencoder)) {
1781 DRM_ERROR("KMS: Failed to initialize connector\n");
1782 goto fail;
1783 }
1784
1785 link = dc_get_link_at_index(dm->dc, i);
^
Which would be a problem here. Can we just delete the misleading
AMDGPU_DM_MAX_DISPLAY_INDEX comparison?
1786
1787 if (!dc_link_detect_sink(link, &new_connection_type))
1788 DRM_ERROR("KMS: Failed to detect connector\n");
1789
1790 if (aconnector->base.force && new_connection_type == dc_connection_none) {
1791 emulated_link_detect(link);
1792 amdgpu_dm_update_connector_after_detect(aconnector);
1793
1794 } else if (dc_link_detect(link, DETECT_REASON_BOOT)) {
1795 amdgpu_dm_update_connector_after_detect(aconnector);
1796 register_backlight_device(dm, link);
1797 }
1798
1799
1800 }
regards,
dan carpenter
More information about the amd-gfx
mailing list