linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: warn on kick missing
@ 2020-02-06  5:54 Nikita Shubin
  2020-02-06 10:40 ` nikita.shubin
  2020-02-06 20:18 ` Bjorn Andersson
  0 siblings, 2 replies; 4+ messages in thread
From: Nikita Shubin @ 2020-02-06  5:54 UTC (permalink / raw)
  Cc: NShubin, Ohad Ben-Cohen, Bjorn Andersson, linux-remoteproc, linux-kernel

.kick method not set in rproc_ops will result in:

8<--- cut here ---
Unable to handle kernel NULL pointer dereference

in rproc_virtio_notify, after firmware loading.

At least a warning needed on attempt to call missing method.

Signed-off-by: Nikita Shubin <NShubin@topcon.com>
---
 drivers/remoteproc/remoteproc_virtio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 8c07cb2ca8ba..77a81f331e3f 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)

        dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);

+       if (unlikely(rproc->ops->kick == NULL)) {
+               WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
+                       rproc->name);
+               return false;
+       }
+
        rproc->ops->kick(rproc, notifyid);
        return true;
 }
--
2.24.1

Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986.   ­­

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

* Re: [PATCH] remoteproc: warn on kick missing
  2020-02-06  5:54 [PATCH] remoteproc: warn on kick missing Nikita Shubin
@ 2020-02-06 10:40 ` nikita.shubin
  2020-02-06 20:18 ` Bjorn Andersson
  1 sibling, 0 replies; 4+ messages in thread
From: nikita.shubin @ 2020-02-06 10:40 UTC (permalink / raw)
  To: Nikita Shubin
  Cc: Ohad Ben-Cohen, Bjorn Andersson, linux-remoteproc, linux-kernel

Sorry for malformed message, please ignore it.

06.02.2020, 08:53, "Nikita Shubin" <nshubin@topcon.com>:
> .kick method not set in rproc_ops will result in:
>
> 8<--- cut here ---
> Unable to handle kernel NULL pointer dereference
>
> in rproc_virtio_notify, after firmware loading.
>
> At least a warning needed on attempt to call missing method.
>
> Signed-off-by: Nikita Shubin <NShubin@topcon.com>
> ---
>  drivers/remoteproc/remoteproc_virtio.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
> index 8c07cb2ca8ba..77a81f331e3f 100644
> --- a/drivers/remoteproc/remoteproc_virtio.c
> +++ b/drivers/remoteproc/remoteproc_virtio.c
> @@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
>
>         dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);
>
> + if (unlikely(rproc->ops->kick == NULL)) {
> + WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
> + rproc->name);
> + return false;
> + }
> +
>         rproc->ops->kick(rproc, notifyid);
>         return true;
>  }
> --
> 2.24.1
>
> Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986. ­­

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

* Re: [PATCH] remoteproc: warn on kick missing
  2020-02-06  5:54 [PATCH] remoteproc: warn on kick missing Nikita Shubin
  2020-02-06 10:40 ` nikita.shubin
@ 2020-02-06 20:18 ` Bjorn Andersson
  2020-02-07  6:30   ` Nikita Shubin
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Andersson @ 2020-02-06 20:18 UTC (permalink / raw)
  To: Nikita Shubin; +Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel

On Wed 05 Feb 21:54 PST 2020, Nikita Shubin wrote:

> .kick method not set in rproc_ops will result in:
> 
> 8<--- cut here ---
> Unable to handle kernel NULL pointer dereference
> 
> in rproc_virtio_notify, after firmware loading.
> 
> At least a warning needed on attempt to call missing method.

Is this not a fatal error only happening during development? In which
case the NULL pointer dereference will come with an oops with sufficient
information to pinpoint what's going on?

Regards,
Bjorn

> 
> Signed-off-by: Nikita Shubin <NShubin@topcon.com>
> ---
>  drivers/remoteproc/remoteproc_virtio.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
> index 8c07cb2ca8ba..77a81f331e3f 100644
> --- a/drivers/remoteproc/remoteproc_virtio.c
> +++ b/drivers/remoteproc/remoteproc_virtio.c
> @@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
> 
>         dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);
> 
> +       if (unlikely(rproc->ops->kick == NULL)) {
> +               WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
> +                       rproc->name);
> +               return false;
> +       }
> +
>         rproc->ops->kick(rproc, notifyid);
>         return true;
>  }
> --
> 2.24.1
> 
> Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986.   ??

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

* Re: [PATCH] remoteproc: warn on kick missing
  2020-02-06 20:18 ` Bjorn Andersson
@ 2020-02-07  6:30   ` Nikita Shubin
  0 siblings, 0 replies; 4+ messages in thread
From: Nikita Shubin @ 2020-02-07  6:30 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Nikita Shubin, Ohad Ben-Cohen, linux-remoteproc, linux-kernel

On Thu, Feb 06, 2020 at 12:18:27PM -0800, Bjorn Andersson wrote:
> On Wed 05 Feb 21:54 PST 2020, Nikita Shubin wrote:
> 
> > .kick method not set in rproc_ops will result in:
> > 
> > 8<--- cut here ---
> > Unable to handle kernel NULL pointer dereference
> > 
> > in rproc_virtio_notify, after firmware loading.
> > 
> > At least a warning needed on attempt to call missing method.
> 
> Is this not a fatal error only happening during development? In which
> case the NULL pointer dereference will come with an oops with sufficient
> information to pinpoint what's going on?

Hello, Bjorn.

This error is happenning if no kick method was defined for struct
rproc_ops, like, for example, in imx_rproc. 

Looks, like if we have a resource table with defined vring's in it, a
virtqueue will be allocated in rp_find_vq, passing rproc_virtio_notify.

But may be it's a better way to refuse calling vring_new_virtqueue if kick
method method is not defined. To avoid explicit load in rproc_virtio_notify.

> 
> Regards,
> Bjorn
> 
> > 
> > Signed-off-by: Nikita Shubin <NShubin@topcon.com>
> > ---
> >  drivers/remoteproc/remoteproc_virtio.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
> > index 8c07cb2ca8ba..77a81f331e3f 100644
> > --- a/drivers/remoteproc/remoteproc_virtio.c
> > +++ b/drivers/remoteproc/remoteproc_virtio.c
> > @@ -32,6 +32,12 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
> > 
> >         dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid);
> > 
> > +       if (unlikely(rproc->ops->kick == NULL)) {
> > +               WARN_ONCE(rproc->ops->kick == NULL, ".kick method not defined for %s",
> > +                       rproc->name);
> > +               return false;
> > +       }
> > +
> >         rproc->ops->kick(rproc, notifyid);
> >         return true;
> >  }
> > --
> > 2.24.1
> > 
> > Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986.   ??

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

end of thread, other threads:[~2020-02-07  6:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06  5:54 [PATCH] remoteproc: warn on kick missing Nikita Shubin
2020-02-06 10:40 ` nikita.shubin
2020-02-06 20:18 ` Bjorn Andersson
2020-02-07  6:30   ` Nikita Shubin

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).