[PATCH v2 2/2] drm: automatic legacy gamma support

kernel test robot lkp at intel.com
Thu Dec 10 18:06:21 UTC 2020


Hi Tomi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on linus/master v5.10-rc7]
[cannot apply to drm-tip/drm-tip anholt/for-next next-20201210]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tomi-Valkeinen/drm-fix-and-cleanup-legacy-gamma-support/20201208-215917
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-m021-20201209 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>

New smatch warnings:
drivers/gpu/drm/drm_color_mgmt.c:307 drm_crtc_legacy_gamma_set() error: potential null dereference 'blob'.  (drm_property_create_blob returns null)

Old smatch warnings:
drivers/gpu/drm/drm_color_mgmt.c:214 drm_mode_crtc_set_gamma_size() warn: double check that we're allocating correct size: 2 vs 6

vim +/blob +307 drivers/gpu/drm/drm_color_mgmt.c

   253	
   254	/**
   255	 * drm_crtc_legacy_gamma_set - set the legacy gamma correction table
   256	 * @crtc: CRTC object
   257	 * @red: red correction table
   258	 * @green: green correction table
   259	 * @blue: green correction table
   260	 * @size: size of the tables
   261	 * @ctx: lock acquire context
   262	 *
   263	 * Implements support for legacy gamma correction table for drivers
   264	 * that have set drm_crtc_funcs.gamma_set or that support color management
   265	 * through the DEGAMMA_LUT/GAMMA_LUT properties. See
   266	 * drm_crtc_enable_color_mgmt() and the containing chapter for
   267	 * how the atomic color management and gamma tables work.
   268	 *
   269	 * This function sets the gamma using the first one available:
   270	 * - drm_crtc_funcs.gamma_set()
   271	 * - GAMMA_LUT
   272	 * - DEGAMMA_LUT
   273	 */
   274	int drm_crtc_legacy_gamma_set(struct drm_crtc *crtc,
   275				      u16 *red, u16 *green, u16 *blue,
   276				      uint32_t size,
   277				      struct drm_modeset_acquire_ctx *ctx)
   278	{
   279		struct drm_device *dev = crtc->dev;
   280		struct drm_atomic_state *state;
   281		struct drm_crtc_state *crtc_state;
   282		struct drm_property_blob *blob = NULL;
   283		struct drm_color_lut *blob_data;
   284		int i, ret = 0;
   285		bool replaced;
   286	
   287		if (crtc->funcs->gamma_set)
   288			return crtc->funcs->gamma_set(crtc, red, green, blue, size, ctx);
   289	
   290		if (!crtc->has_gamma_prop && !crtc->has_degamma_prop)
   291			return -ENODEV;
   292	
   293		state = drm_atomic_state_alloc(crtc->dev);
   294		if (!state)
   295			return -ENOMEM;
   296	
   297		blob = drm_property_create_blob(dev,
   298						sizeof(struct drm_color_lut) * size,
   299						NULL);
   300		if (IS_ERR(blob)) {
   301			ret = PTR_ERR(blob);
   302			blob = NULL;
   303			goto fail;
   304		}
   305	
   306		/* Prepare GAMMA_LUT with the legacy values. */
 > 307		blob_data = blob->data;
   308		for (i = 0; i < size; i++) {
   309			blob_data[i].red = red[i];
   310			blob_data[i].green = green[i];
   311			blob_data[i].blue = blue[i];
   312		}
   313	
   314		state->acquire_ctx = ctx;
   315		crtc_state = drm_atomic_get_crtc_state(state, crtc);
   316		if (IS_ERR(crtc_state)) {
   317			ret = PTR_ERR(crtc_state);
   318			goto fail;
   319		}
   320	
   321		/* Set GAMMA/DEGAMMA_LUT and reset DEGAMMA/GAMMA_LUT and CTM */
   322		replaced  = drm_property_replace_blob(&crtc_state->degamma_lut,
   323						      crtc->has_gamma_prop ? NULL : blob);
   324		replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
   325		replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
   326						      crtc->has_gamma_prop ? blob : NULL);
   327		crtc_state->color_mgmt_changed |= replaced;
   328	
   329		ret = drm_atomic_commit(state);
   330	
   331	fail:
   332		drm_atomic_state_put(state);
   333		drm_property_blob_put(blob);
   334		return ret;
   335	}
   336	EXPORT_SYMBOL(drm_crtc_legacy_gamma_set);
   337	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 36289 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20201211/8bf2006c/attachment-0001.gz>


More information about the dri-devel mailing list