linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rpmsg: glink: Avoid infinite loop on intent for missing channel
@ 2023-01-09 22:38 Bjorn Andersson
  2023-02-14 22:55 ` Chris Lew
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Andersson @ 2023-01-09 22:38 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: Sricharan Ramabadhran, Arun Kumar Neelakantam, linux-arm-msm,
	linux-remoteproc, linux-kernel

In the event that an intent advertisement arrives on an unknown channel
the fifo is not advanced, resulting in the same message being handled
over and over.

Fixes: dacbb35e930f ("rpmsg: glink: Receive and store the remote intent buffers")
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
 drivers/rpmsg/qcom_glink_native.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index f36740cb6866..7b1320b1579e 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -946,12 +946,12 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,
 	spin_unlock_irqrestore(&glink->idr_lock, flags);
 	if (!channel) {
 		dev_err(glink->dev, "intents for non-existing channel\n");
-		return;
+		goto advance_rx;
 	}
 
 	msg = kmalloc(msglen, GFP_ATOMIC);
 	if (!msg)
-		return;
+		goto advance_rx;
 
 	qcom_glink_rx_peak(glink, msg, 0, msglen);
 
@@ -973,6 +973,7 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,
 	}
 
 	kfree(msg);
+advance_rx:
 	qcom_glink_rx_advance(glink, ALIGN(msglen, 8));
 }
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rpmsg: glink: Avoid infinite loop on intent for missing channel
  2023-01-09 22:38 [PATCH] rpmsg: glink: Avoid infinite loop on intent for missing channel Bjorn Andersson
@ 2023-02-14 22:55 ` Chris Lew
  2023-02-14 23:34   ` Bjorn Andersson
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Lew @ 2023-02-14 22:55 UTC (permalink / raw)
  To: Bjorn Andersson, Bjorn Andersson, Mathieu Poirier
  Cc: Sricharan Ramabadhran, Arun Kumar Neelakantam, linux-arm-msm,
	linux-remoteproc, linux-kernel, quic_clew

On 1/9/2023 2:38 PM, Bjorn Andersson wrote:
> In the event that an intent advertisement arrives on an unknown channel
> the fifo is not advanced, resulting in the same message being handled
> over and over.
> 
> Fixes: dacbb35e930f ("rpmsg: glink: Receive and store the remote intent buffers")
> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
> ---
>   drivers/rpmsg/qcom_glink_native.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> index f36740cb6866..7b1320b1579e 100644
> --- a/drivers/rpmsg/qcom_glink_native.c
> +++ b/drivers/rpmsg/qcom_glink_native.c
> @@ -946,12 +946,12 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,
>   	spin_unlock_irqrestore(&glink->idr_lock, flags);
>   	if (!channel) {
>   		dev_err(glink->dev, "intents for non-existing channel\n");
> -		return;
> +		goto advance_rx;
>   	}
>   
>   	msg = kmalloc(msglen, GFP_ATOMIC);
>   	if (!msg)
> -		return;
> +		goto advance_rx;


Should we be dropping the packet for this case? If we try again later 
more memory might be available to handle the command.

>   
>   	qcom_glink_rx_peak(glink, msg, 0, msglen);
>   
> @@ -973,6 +973,7 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,
>   	}
>   
>   	kfree(msg);
> +advance_rx:
>   	qcom_glink_rx_advance(glink, ALIGN(msglen, 8));
>   }
>   
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rpmsg: glink: Avoid infinite loop on intent for missing channel
  2023-02-14 22:55 ` Chris Lew
@ 2023-02-14 23:34   ` Bjorn Andersson
  0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2023-02-14 23:34 UTC (permalink / raw)
  To: Chris Lew
  Cc: Bjorn Andersson, Mathieu Poirier, Sricharan Ramabadhran,
	Arun Kumar Neelakantam, linux-arm-msm, linux-remoteproc,
	linux-kernel

On Tue, Feb 14, 2023 at 02:55:02PM -0800, Chris Lew wrote:
> On 1/9/2023 2:38 PM, Bjorn Andersson wrote:
> > In the event that an intent advertisement arrives on an unknown channel
> > the fifo is not advanced, resulting in the same message being handled
> > over and over.
> > 
> > Fixes: dacbb35e930f ("rpmsg: glink: Receive and store the remote intent buffers")
> > Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
> > ---
> >   drivers/rpmsg/qcom_glink_native.c | 5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> > index f36740cb6866..7b1320b1579e 100644
> > --- a/drivers/rpmsg/qcom_glink_native.c
> > +++ b/drivers/rpmsg/qcom_glink_native.c
> > @@ -946,12 +946,12 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,
> >   	spin_unlock_irqrestore(&glink->idr_lock, flags);
> >   	if (!channel) {
> >   		dev_err(glink->dev, "intents for non-existing channel\n");
> > -		return;
> > +		goto advance_rx;
> >   	}
> >   	msg = kmalloc(msglen, GFP_ATOMIC);
> >   	if (!msg)
> > -		return;
> > +		goto advance_rx;
> 
> 
> Should we be dropping the packet for this case? If we try again later more
> memory might be available to handle the command.
> 

You're right, we found a channel above, but we don't have enough memory
to handle the message right now. That seems like a message worth not
throwing away.

Thanks,
Bjorn

> >   	qcom_glink_rx_peak(glink, msg, 0, msglen);
> > @@ -973,6 +973,7 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,
> >   	}
> >   	kfree(msg);
> > +advance_rx:
> >   	qcom_glink_rx_advance(glink, ALIGN(msglen, 8));
> >   }
> > 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-14 23:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 22:38 [PATCH] rpmsg: glink: Avoid infinite loop on intent for missing channel Bjorn Andersson
2023-02-14 22:55 ` Chris Lew
2023-02-14 23:34   ` Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).