Message ID | 20241210121955.992519-1-joe@pf.is.s.u-tokyo.ac.jp (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | soc: qcom: smem_state: fix an OF node reference leak in qcom_smem_state_get() | expand |
On 10.12.2024 1:19 PM, Joe Hattori wrote: > qcom_smem_state_get() leaks an OF node when args.args_count != 1 holds. > Add a of_node_put() call before returning an error. > > This bug was found by an experimental static analysis tool that I am > currently developing. > > Fixes: 9460ae2ff308 ("soc: qcom: Introduce common SMEM state machine code") > Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> > --- Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Konrad
diff --git a/drivers/soc/qcom/smem_state.c b/drivers/soc/qcom/smem_state.c index d9bfac6c54fb..6a477e3c1316 100644 --- a/drivers/soc/qcom/smem_state.c +++ b/drivers/soc/qcom/smem_state.c @@ -112,6 +112,7 @@ struct qcom_smem_state *qcom_smem_state_get(struct device *dev, if (args.args_count != 1) { dev_err(dev, "invalid #qcom,smem-state-cells\n"); + of_node_put(args.np); return ERR_PTR(-EINVAL); }
qcom_smem_state_get() leaks an OF node when args.args_count != 1 holds. Add a of_node_put() call before returning an error. This bug was found by an experimental static analysis tool that I am currently developing. Fixes: 9460ae2ff308 ("soc: qcom: Introduce common SMEM state machine code") Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> --- drivers/soc/qcom/smem_state.c | 1 + 1 file changed, 1 insertion(+)