Skip to content

Commit 74007ae

Browse files
tititiou36groeck
authored andcommitted
hwmon: (xgene) Fix up error handling path mixup in 'xgene_hwmon_probe()'
Commit 2ca492e has moved the call to 'kfifo_alloc()' from after the main 'if' statement to before it. But it has not updated the error handling paths accordingly. Fix all that: - if 'kfifo_alloc()' fails we can return directly - direct returns after 'kfifo_alloc()' must now go to 'out_mbox_free' - 'goto out_mbox_free' must be replaced by 'goto out', otherwise the '[pcc_]mbox_free_channel()' call will be missed. Fixes: 2ca492e ("hwmon: (xgene) Fix crash when alarm occurs before driver probe") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 2bd6bf0 commit 74007ae

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/hwmon/xgene-hwmon.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
630630
sizeof(struct slimpro_resp_msg) * ASYNC_MSG_FIFO_SIZE,
631631
GFP_KERNEL);
632632
if (rc)
633-
goto out_mbox_free;
633+
return -ENOMEM;
634634

635635
INIT_WORK(&ctx->workq, xgene_hwmon_evt_work);
636636

@@ -646,23 +646,26 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
646646
if (IS_ERR(ctx->mbox_chan)) {
647647
dev_err(&pdev->dev,
648648
"SLIMpro mailbox channel request failed\n");
649-
return -ENODEV;
649+
rc = -ENODEV;
650+
goto out_mbox_free;
650651
}
651652
} else {
652653
struct acpi_pcct_hw_reduced *cppc_ss;
653654

654655
if (device_property_read_u32(&pdev->dev, "pcc-channel",
655656
&ctx->mbox_idx)) {
656657
dev_err(&pdev->dev, "no pcc-channel property\n");
657-
return -ENODEV;
658+
rc = -ENODEV;
659+
goto out_mbox_free;
658660
}
659661

660662
cl->rx_callback = xgene_hwmon_pcc_rx_cb;
661663
ctx->mbox_chan = pcc_mbox_request_channel(cl, ctx->mbox_idx);
662664
if (IS_ERR(ctx->mbox_chan)) {
663665
dev_err(&pdev->dev,
664666
"PPC channel request failed\n");
665-
return -ENODEV;
667+
rc = -ENODEV;
668+
goto out_mbox_free;
666669
}
667670

668671
/*
@@ -675,13 +678,13 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
675678
if (!cppc_ss) {
676679
dev_err(&pdev->dev, "PPC subspace not found\n");
677680
rc = -ENODEV;
678-
goto out_mbox_free;
681+
goto out;
679682
}
680683

681684
if (!ctx->mbox_chan->mbox->txdone_irq) {
682685
dev_err(&pdev->dev, "PCC IRQ not supported\n");
683686
rc = -ENODEV;
684-
goto out_mbox_free;
687+
goto out;
685688
}
686689

687690
/*
@@ -696,14 +699,14 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
696699
} else {
697700
dev_err(&pdev->dev, "Failed to get PCC comm region\n");
698701
rc = -ENODEV;
699-
goto out_mbox_free;
702+
goto out;
700703
}
701704

702705
if (!ctx->pcc_comm_addr) {
703706
dev_err(&pdev->dev,
704707
"Failed to ioremap PCC comm region\n");
705708
rc = -ENOMEM;
706-
goto out_mbox_free;
709+
goto out;
707710
}
708711

709712
/*

0 commit comments

Comments
 (0)