Sfoglia il codice sorgente

ubwcp: reject set attr req with invalid dimensions

Zero is not valid size for width/height/stride/scanlines. Reject
such calls. Also added check to not attempt ula allocation when
calculated ula_size is zero.

Change-Id: If6cddbd9d59c97a7acefd44b3c3985e01209f54e
Signed-off-by: Amol Jadi <[email protected]>
Amol Jadi 1 anno fa
parent
commit
cda03c3582
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. 10 0
      ubwcp/ubwcp_main.c

+ 10 - 0
ubwcp/ubwcp_main.c

@@ -928,6 +928,11 @@ static bool ubwcp_buf_attrs_valid(struct ubwcp_driver *ubwcp, struct ubwcp_buffe
 		goto err;
 	}
 
+	if (!attr->width || !attr->height || !attr->stride || !attr->scanlines) {
+		ERR("width/height/stride/scanlines cannot be 0");
+		goto err;
+	}
+
 	if (!ioctl_format_is_valid(attr->image_format)) {
 		ERR("invalid image format: %d", attr->image_format);
 		goto err;
@@ -1709,6 +1714,11 @@ int ubwcp_set_buf_attrs(struct dma_buf *dmabuf, struct ubwcp_buffer_attrs *attr)
 	DBG_BUF_ATTR("iova_min_size   : %8d (0x%8zx)", iova_min_size, iova_min_size);
 	DBG_BUF_ATTR("");
 
+	if (!ula_size) {
+		ERR("Invalid ula_size (0)");
+		goto unlock;
+	}
+
 	/* assign ULA PA with uncompressed-size range */
 	ula_pa = ubwcp_ula_realloc(ubwcp, buf->ula_pa, buf->ula_size, ula_size);
 	if (!ula_pa) {