]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bus: mhi: host: Free mhi_buf vector inside mhi_alloc_bhie_table()
authorYoussef Samir <quic_yabdulra@quicinc.com>
Thu, 24 Oct 2024 21:47:15 +0000 (23:47 +0200)
committerManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Mon, 2 Dec 2024 09:31:06 +0000 (15:01 +0530)
mhi_alloc_bhie_table() starts by allocating a vector of struct mhi_buf
then it allocates a DMA buffer for each element. If allocation fails,
it will free the allocated DMA buffers, but it neglects freeing the
mhi_buf vector.

Avoid memory leaks by freeing the mhi_buf vector on error.

Fixes: 3000f85b8f47 ("bus: mhi: core: Add support for basic PM operations")
Signed-off-by: Youssef Samir <quic_yabdulra@quicinc.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20241024214715.1208940-1-quic_yabdulra@quicinc.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
drivers/bus/mhi/host/boot.c

index e8c92972f9df92bc836e9608a2401b64b35ecc5a..9dcc7184817d51d8fad6aa2be8b7e1663a9b509c 100644 (file)
@@ -357,6 +357,7 @@ error_alloc_segment:
        for (--i, --mhi_buf; i >= 0; i--, mhi_buf--)
                dma_free_coherent(mhi_cntrl->cntrl_dev, mhi_buf->len,
                                  mhi_buf->buf, mhi_buf->dma_addr);
+       kfree(img_info->mhi_buf);
 
 error_alloc_mhi_buf:
        kfree(img_info);