2021-02-01 12:26:24

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH] misc: bcm-vk: unlock on error in bcm_to_h_msg_dequeue()

Unlock before returning on this error path.

Fixes: 111d746bb476 ("misc: bcm-vk: add VK messaging support")
Signed-off-by: Dan Carpenter <[email protected]>
---
drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/bcm-vk/bcm_vk_msg.c b/drivers/misc/bcm-vk/bcm_vk_msg.c
index eec90494777d..fc972e43258a 100644
--- a/drivers/misc/bcm-vk/bcm_vk_msg.c
+++ b/drivers/misc/bcm-vk/bcm_vk_msg.c
@@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
* that is fatal.
*/
dev_crit(dev, "Kernel mem allocation failure.\n");
- return -ENOMEM;
+ total = -ENOMEM;
+ goto idx_err;
}

/* flush rd pointer after a message is dequeued */
--
2.29.2


2021-02-01 17:34:51

by Scott Branden

[permalink] [raw]
Subject: Re: [PATCH] misc: bcm-vk: unlock on error in bcm_to_h_msg_dequeue()



On 2021-02-01 4:22 a.m., Dan Carpenter wrote:
> Unlock before returning on this error path.
>
> Fixes: 111d746bb476 ("misc: bcm-vk: add VK messaging support")
> Signed-off-by: Dan Carpenter <[email protected]>
> ---
> drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/bcm-vk/bcm_vk_msg.c b/drivers/misc/bcm-vk/bcm_vk_msg.c
> index eec90494777d..fc972e43258a 100644
> --- a/drivers/misc/bcm-vk/bcm_vk_msg.c
> +++ b/drivers/misc/bcm-vk/bcm_vk_msg.c
> @@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
> * that is fatal.
> */
> dev_crit(dev, "Kernel mem allocation failure.\n");
> - return -ENOMEM;
> + total = -ENOMEM;
> + goto idx_err;
> }
>
This is a pretty fatal case if we fail to allocate memory here.
Will let Desmond respond if we wanted to keep the mutex locked forever in this
case or if we do want to return and keep mutex locked if it is fatal and there is
no real recovery path.
> /* flush rd pointer after a message is dequeued */

2021-02-01 18:36:47

by Desmond Yan

[permalink] [raw]
Subject: Re: [PATCH] misc: bcm-vk: unlock on error in bcm_to_h_msg_dequeue()

Acked-by: Desmond Yan <[email protected]>

On Mon, Feb 1, 2021 at 4:24 AM Dan Carpenter <[email protected]> wrote:
>
> Unlock before returning on this error path.
>
> Fixes: 111d746bb476 ("misc: bcm-vk: add VK messaging support")
> Signed-off-by: Dan Carpenter <[email protected]>
> ---
> drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/bcm-vk/bcm_vk_msg.c b/drivers/misc/bcm-vk/bcm_vk_msg.c
> index eec90494777d..fc972e43258a 100644
> --- a/drivers/misc/bcm-vk/bcm_vk_msg.c
> +++ b/drivers/misc/bcm-vk/bcm_vk_msg.c
> @@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
> * that is fatal.
> */
> dev_crit(dev, "Kernel mem allocation failure.\n");
> - return -ENOMEM;
> + total = -ENOMEM;
> + goto idx_err;
> }
>
> /* flush rd pointer after a message is dequeued */
> --
> 2.29.2
>


Attachments:
smime.p7s (4.07 kB)
S/MIME Cryptographic Signature

2021-02-01 18:37:08

by Desmond Yan

[permalink] [raw]
Subject: Re: [PATCH] misc: bcm-vk: unlock on error in bcm_to_h_msg_dequeue()

Yes, in this situation, it is fatal and we would turn off processing
anyway. But, Dan's change seems more appropriate and proper practice
(thxs for the patch).

Des

On Mon, Feb 1, 2021 at 9:31 AM Scott Branden <[email protected]> wrote:
>
>
>
> On 2021-02-01 4:22 a.m., Dan Carpenter wrote:
> > Unlock before returning on this error path.
> >
> > Fixes: 111d746bb476 ("misc: bcm-vk: add VK messaging support")
> > Signed-off-by: Dan Carpenter <[email protected]>
> > ---
> > drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/misc/bcm-vk/bcm_vk_msg.c b/drivers/misc/bcm-vk/bcm_vk_msg.c
> > index eec90494777d..fc972e43258a 100644
> > --- a/drivers/misc/bcm-vk/bcm_vk_msg.c
> > +++ b/drivers/misc/bcm-vk/bcm_vk_msg.c
> > @@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
> > * that is fatal.
> > */
> > dev_crit(dev, "Kernel mem allocation failure.\n");
> > - return -ENOMEM;
> > + total = -ENOMEM;
> > + goto idx_err;
> > }
> >
> This is a pretty fatal case if we fail to allocate memory here.
> Will let Desmond respond if we wanted to keep the mutex locked forever in this
> case or if we do want to return and keep mutex locked if it is fatal and there is
> no real recovery path.
> > /* flush rd pointer after a message is dequeued */
>


Attachments:
smime.p7s (4.06 kB)
S/MIME Cryptographic Signature

2021-02-01 22:52:36

by Scott Branden

[permalink] [raw]
Subject: Re: [PATCH] misc: bcm-vk: unlock on error in bcm_to_h_msg_dequeue()

Great, looks good then.

On 2021-02-01 10:32 a.m., Desmond Yan wrote:
> Acked-by: Desmond Yan <[email protected]>
Acked-by: Scott Branden <[email protected]>
>
> On Mon, Feb 1, 2021 at 4:24 AM Dan Carpenter <[email protected]> wrote:
>> Unlock before returning on this error path.
>>
>> Fixes: 111d746bb476 ("misc: bcm-vk: add VK messaging support")
>> Signed-off-by: Dan Carpenter <[email protected]>
>> ---
>> drivers/misc/bcm-vk/bcm_vk_msg.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/misc/bcm-vk/bcm_vk_msg.c b/drivers/misc/bcm-vk/bcm_vk_msg.c
>> index eec90494777d..fc972e43258a 100644
>> --- a/drivers/misc/bcm-vk/bcm_vk_msg.c
>> +++ b/drivers/misc/bcm-vk/bcm_vk_msg.c
>> @@ -849,7 +849,8 @@ s32 bcm_to_h_msg_dequeue(struct bcm_vk *vk)
>> * that is fatal.
>> */
>> dev_crit(dev, "Kernel mem allocation failure.\n");
>> - return -ENOMEM;
>> + total = -ENOMEM;
>> + goto idx_err;
>> }
>>
>> /* flush rd pointer after a message is dequeued */
>> --
>> 2.29.2
>>