Skip to contentSkip to conversation

soc: qcom: geni: Provide parameter error checking

PATCH RESEND New Lee Jones 1 participant 1 message Sep 5, 2019

Subsystems (2)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

PATCH RESEND 1/1 soc: qcom: geni: Provide parameter error checking

When booting with ACPI, the Geni Serial Engine is not set as the I2C/SPI parent and thus, the wrapper (parent device) is unassigned. This causes the kernel to crash with a null dereference error.

Fixes 8bc529b25354 ("soc: qcom: geni: Add support for ACPI")

---
* Collecting Acks

NB: If someone could send this to Linus for -rc7, it would make v5.3 work
when booting with ACPI, meaning the newly released distros, due out in October will be bootable. I'd be happy to send it myself with a nod from someone prominant (QCom, Andy, Bjorn, etc).

drivers/soc/qcom/qcom-geni-se.c | 6 ++++++

 1 file changed, 6 insertions(+)
drivers/soc/qcom/qcom-geni-se.c +6 -0
index d5cf953b4337..7d622ea1274e 100644
@@ -630,6 +630,9 @@ int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len,
 	struct geni_wrapper *wrapper = se->wrapper;
 	u32 val;
 
+	if (!wrapper)
+		return -EINVAL;
+
 	*iova = dma_map_single(wrapper->dev, buf, len, DMA_TO_DEVICE);
 	if (dma_mapping_error(wrapper->dev, *iova))
 		return -EIO;
@@ -663,6 +666,9 @@ int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len,
 	struct geni_wrapper *wrapper = se->wrapper;
 	u32 val;
 
+	if (!wrapper)
+		return -EINVAL;
+
 	*iova = dma_map_single(wrapper->dev, buf, len, DMA_FROM_DEVICE);
 	if (dma_mapping_error(wrapper->dev, *iova))
 		return -EIO;
Signature · 1 line
2.17.1