Skip to content

Commit 03c900b

Browse files
Akash Asthanaandersson
authored andcommitted
soc: qcom: geni: Fix NULL pointer dereference
pdev struct doesn't exits for the devices whose status are disabled from DT node, in such cases NULL is returned from 'of_find_device_by_node' Later when we try to get drvdata from pdev struct NULL pointer dereference is triggered. Add a NULL check for return values to fix the issue. We were hitting this issue when one of QUP is disabled. Reviewed-by: Matthias Kaehlcke <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Tested-by: Bjorn Andersson <[email protected]> Fixes: 048eb90 ("soc: qcom-geni-se: Add interconnect support to fix earlycon crash") Reported-by: Sai Prakash Ranjan <[email protected]> Signed-off-by: Akash Asthana <[email protected]> Link: https://lore.kernel.org/r/[email protected] [bjorn: s/wrapper_pdev/pdev/] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 4a3107f commit 03c900b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/soc/qcom/qcom-geni-se.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ EXPORT_SYMBOL(geni_icc_disable);
817817

818818
void geni_remove_earlycon_icc_vote(void)
819819
{
820+
struct platform_device *pdev;
820821
struct geni_wrapper *wrapper;
821822
struct device_node *parent;
822823
struct device_node *child;
@@ -829,7 +830,12 @@ void geni_remove_earlycon_icc_vote(void)
829830
for_each_child_of_node(parent, child) {
830831
if (!of_device_is_compatible(child, "qcom,geni-se-qup"))
831832
continue;
832-
wrapper = platform_get_drvdata(of_find_device_by_node(child));
833+
834+
pdev = of_find_device_by_node(child);
835+
if (!pdev)
836+
continue;
837+
838+
wrapper = platform_get_drvdata(pdev);
833839
icc_put(wrapper->to_core.path);
834840
wrapper->to_core.path = NULL;
835841

0 commit comments

Comments
 (0)