Skip to content

Commit c158ceb

Browse files
quic-bjorandeandersson
authored andcommitted
soc: qcom: pd-mapper: Fix singleton refcount
The Qualcomm pd-mapper is a refcounted singleton, but the refcount is never incremented, which means the as soon as any remoteproc instance stops the count will hit 0. At this point the pd-mapper QMI service is stopped, leaving firmware without access to the PD information. Stopping any other remoteproc instances will result in a use-after-free, which best case manifest itself as a refcount underflow: refcount_t: underflow; use-after-free. WARNING: CPU: 1 PID: 354 at lib/refcount.c:87 refcount_dec_and_mutex_lock+0xc4/0x148 ... Call trace: refcount_dec_and_mutex_lock+0xc4/0x148 qcom_pdm_remove+0x40/0x118 [qcom_pd_mapper] ... Fix this by incrementing the refcount, so that the pd-mapper is only torn down when the last remoteproc stops, as intended. Fixes: 1ebcde0 ("soc: qcom: add pd-mapper implementation") Signed-off-by: Bjorn Andersson <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 8342009 commit c158ceb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/soc/qcom/qcom_pd_mapper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ static int qcom_pdm_probe(struct auxiliary_device *auxdev,
635635
ret = PTR_ERR(data);
636636
else
637637
__qcom_pdm_data = data;
638+
} else {
639+
refcount_inc(&__qcom_pdm_data->refcnt);
638640
}
639641

640642
auxiliary_set_drvdata(auxdev, __qcom_pdm_data);

0 commit comments

Comments
 (0)