From: Rolf Evers-Fischer <embedded24@evers-fischer.de>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Rolf Evers-Fischer <embedded24@evers-fischer.de>,
Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
Linux-sh list <linux-sh@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sh: dma: Add missing IS_ERR test
Date: Tue, 11 Jun 2019 12:20:20 +0200 (CEST) [thread overview]
Message-ID: <alpine.LNX.2.21.99.1906111200560.3086@5HSWXM1> (raw)
In-Reply-To: <CAMuHMdVGhd3KfRq9F+-Qzc7q5kJyczG1RRQDpgs4FqJpPwK4QA@mail.gmail.com>
On Sat, 8 Jun 2019, Geert Uytterhoeven wrote:
Hi Geert,
thank you for your reply and your additional findings.
> Hi Rolf,
>
> Thanks for your patch!
>
> On Fri, Jun 7, 2019 at 2:04 PM Rolf Evers-Fischer
> <embedded24@evers-fischer.de> wrote:
> > get_dma_channel may return ERR_PTR, so a check is added.
>
> It may also return NULL...
Good catch. I must have missed this.
>
> > --- a/arch/sh/drivers/dma/dma-api.c
> > +++ b/arch/sh/drivers/dma/dma-api.c
> > @@ -94,7 +94,7 @@ int get_dma_residue(unsigned int chan)
> > struct dma_info *info = get_dma_info(chan);
> > struct dma_channel *channel = get_dma_channel(chan);
> >
> > - if (info->ops->get_residue)
> > + if (!IS_ERR(channel) && (info->ops->get_residue))
> > return info->ops->get_residue(channel);
>
> ... in which case .get_residue() may crash, as some implementations
> dereference the passed channel pointer.
>
> Hence !IS_ERR_OR_NULL()?
Yes, in fact. IS_ERR_OR_NULL is the better choice here.
I will resend a reworked patch immediately.
>
> I didn't check the other callers.
Well, I did. And I found that none of the implementations checks the
passed pointer. However, no in-tree driver is using the .extend() op, but
as long as we don't know, if any out-of-tree drivers are using it without
any additional check, I would prefer to check for NULL or error in
dma_extend() as well.
Kind regards,
Rolf
prev parent reply other threads:[~2019-06-11 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-07 11:54 Rolf Evers-Fischer
2019-06-08 8:27 ` Sergei Shtylyov
2019-06-11 10:00 ` Rolf Evers-Fischer
2019-06-08 12:26 ` Geert Uytterhoeven
2019-06-11 10:20 ` Rolf Evers-Fischer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.21.99.1906111200560.3086@5HSWXM1 \
--to=embedded24@evers-fischer.de \
--cc=dalias@libc.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®