Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/omap: add omap_gem_validate_flags()

Add a helper function omap_gem_validate_flags() which validates the
omap_bo flags passed from the userspace.

Also drop the dev_err() message, as the userspace can cause that at
will.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191010120000.1421-8-jjhiblot@ti.com

+35 -5
+35 -5
drivers/gpu/drm/omapdrm/omap_gem.c
··· 1133 1133 kfree(omap_obj); 1134 1134 } 1135 1135 1136 + static bool omap_gem_validate_flags(struct drm_device *dev, u32 flags) 1137 + { 1138 + struct omap_drm_private *priv = dev->dev_private; 1139 + 1140 + switch (flags & OMAP_BO_CACHE_MASK) { 1141 + case OMAP_BO_CACHED: 1142 + case OMAP_BO_WC: 1143 + case OMAP_BO_CACHE_MASK: 1144 + break; 1145 + 1146 + default: 1147 + return false; 1148 + } 1149 + 1150 + if (flags & OMAP_BO_TILED_MASK) { 1151 + if (!priv->usergart) 1152 + return false; 1153 + 1154 + switch (flags & OMAP_BO_TILED_MASK) { 1155 + case OMAP_BO_TILED_8: 1156 + case OMAP_BO_TILED_16: 1157 + case OMAP_BO_TILED_32: 1158 + break; 1159 + 1160 + default: 1161 + return false; 1162 + } 1163 + } 1164 + 1165 + return true; 1166 + } 1167 + 1136 1168 /* GEM buffer object constructor */ 1137 1169 struct drm_gem_object *omap_gem_new(struct drm_device *dev, 1138 1170 union omap_gem_size gsize, u32 flags) ··· 1176 1144 size_t size; 1177 1145 int ret; 1178 1146 1147 + if (!omap_gem_validate_flags(dev, flags)) 1148 + return NULL; 1149 + 1179 1150 /* Validate the flags and compute the memory and cache flags. */ 1180 1151 if (flags & OMAP_BO_TILED_MASK) { 1181 - if (!priv->usergart) { 1182 - dev_err(dev->dev, "Tiled buffers require DMM\n"); 1183 - return NULL; 1184 - } 1185 - 1186 1152 /* 1187 1153 * Tiled buffers are always shmem paged backed. When they are 1188 1154 * scanned out, they are remapped into DMM/TILER.