diff mbox series

[v4,1/5] mailbox: zynqmp: fix counts of child nodes

Message ID 20230228210216.447373-2-tanmay.shah@amd.com (mailing list archive)
State Superseded
Headers show
Series drivers: remoteproc: xilinx: add mailbox support | expand

Commit Message

Tanmay Shah Feb. 28, 2023, 9:02 p.m. UTC
If child mailbox node status is disabled it causes
crash in interrupt handler. Fix this by assigning
only available child node during driver probe.

Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
---
 drivers/mailbox/zynqmp-ipi-mailbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Simek March 8, 2023, 11:53 a.m. UTC | #1
On 2/28/23 22:02, Tanmay Shah wrote:
> If child mailbox node status is disabled it causes
> crash in interrupt handler. Fix this by assigning
> only available child node during driver probe.
> 
> Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
> ---
>   drivers/mailbox/zynqmp-ipi-mailbox.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
> index 12e004ff1a14..e287ed7a92ce 100644
> --- a/drivers/mailbox/zynqmp-ipi-mailbox.c
> +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
> @@ -634,7 +634,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
>   	struct zynqmp_ipi_mbox *mbox;
>   	int num_mboxes, ret = -EINVAL;
>   
> -	num_mboxes = of_get_child_count(np);
> +	num_mboxes = of_get_available_child_count(np);
>   	pdata = devm_kzalloc(dev, sizeof(*pdata) + (num_mboxes * sizeof(*mbox)),
>   			     GFP_KERNEL);
>   	if (!pdata)

I think it will be good to also check that num_mboxes is != 0.

M
Tanmay Shah March 9, 2023, 8:30 p.m. UTC | #2
On 3/8/23 5:53 AM, Michal Simek wrote:
>
>
> On 2/28/23 22:02, Tanmay Shah wrote:
>> If child mailbox node status is disabled it causes
>> crash in interrupt handler. Fix this by assigning
>> only available child node during driver probe.
>>
>> Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
>> ---
>>   drivers/mailbox/zynqmp-ipi-mailbox.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c 
>> b/drivers/mailbox/zynqmp-ipi-mailbox.c
>> index 12e004ff1a14..e287ed7a92ce 100644
>> --- a/drivers/mailbox/zynqmp-ipi-mailbox.c
>> +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
>> @@ -634,7 +634,7 @@ static int zynqmp_ipi_probe(struct 
>> platform_device *pdev)
>>       struct zynqmp_ipi_mbox *mbox;
>>       int num_mboxes, ret = -EINVAL;
>>   -    num_mboxes = of_get_child_count(np);
>> +    num_mboxes = of_get_available_child_count(np);
>>       pdata = devm_kzalloc(dev, sizeof(*pdata) + (num_mboxes * 
>> sizeof(*mbox)),
>>                    GFP_KERNEL);
>>       if (!pdata)
>
> I think it will be good to also check that num_mboxes is != 0.

Ack, I will fix this in next revision.


>
> M
diff mbox series

Patch

diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c
index 12e004ff1a14..e287ed7a92ce 100644
--- a/drivers/mailbox/zynqmp-ipi-mailbox.c
+++ b/drivers/mailbox/zynqmp-ipi-mailbox.c
@@ -634,7 +634,7 @@  static int zynqmp_ipi_probe(struct platform_device *pdev)
 	struct zynqmp_ipi_mbox *mbox;
 	int num_mboxes, ret = -EINVAL;
 
-	num_mboxes = of_get_child_count(np);
+	num_mboxes = of_get_available_child_count(np);
 	pdata = devm_kzalloc(dev, sizeof(*pdata) + (num_mboxes * sizeof(*mbox)),
 			     GFP_KERNEL);
 	if (!pdata)