linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Kitt <steve@sk2.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-input@vger.kernel.org
Subject: Re: Input: joydev - validate axis/button maps before clobbering current ones
Date: Tue, 6 Oct 2015 22:57:26 +0200	[thread overview]
Message-ID: <20151006225726.545f4ce5@heffalump.sk2.org> (raw)
In-Reply-To: <20151006185155.GA8997@mwanda>

[-- Attachment #1: Type: text/plain, Size: 1715 bytes --]

Hello Dan,

On Tue, 6 Oct 2015 21:51:55 +0300, Dan Carpenter <dan.carpenter@oracle.com>
wrote:
> The patch 999b874f4aa3: "Input: joydev - validate axis/button maps
> before clobbering current ones" from Aug 25, 2009, leads to the
> following static checker warning:
> 
> 	drivers/input/joydev.c:466 joydev_handle_JSIOCSAXMAP()
> 	error: 'abspam' dereferencing possible ERR_PTR()
> 
> drivers/input/joydev.c
>    437  static int joydev_handle_JSIOCSAXMAP(struct joydev *joydev,
>    438                                       void __user *argp, size_t len)
>    439  {
>    440          __u8 *abspam;
>    441          int i;
>    442          int retval = 0;
>    443  
>    444          len = min(len, sizeof(joydev->abspam));
>    445  
>    446          /* Validate the map. */
>    447          abspam = memdup_user(argp, len);
>    448          if (IS_ERR(abspam)) {
>    449                  retval = PTR_ERR(abspam);
>    450                  goto out;
> 
> out labels are error prone.  It's safer to return directly.
> 
> https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
> 
> joydev_handle_JSIOCSBTNMAP() has the same issue.

Perhaps I'm missing something here, but that's not the code I wrote, nor is
it the code that's currently in the kernel. What I have in my copy of the
kernel tree is

        /* Validate the map. */
        abspam = kmalloc(len, GFP_KERNEL);
        if (!abspam)
                return -ENOMEM;

which does as you recommend. If you look up the commit you're referring to
you'll see that's also the code as I wrote it back in 2009; I'm not sure
where your IS_ERR() and PTR_ERR() stuff is coming from.

Regards,

Stephen

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-10-07  1:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 18:51 Input: joydev - validate axis/button maps before clobbering current ones Dan Carpenter
2015-10-06 20:57 ` Stephen Kitt [this message]
2015-10-06 21:01   ` Stephen Kitt
2015-10-06 21:49     ` Javier Martinez Canillas
2015-10-06 22:49       ` Dmitry Torokhov
2015-10-06 23:31         ` Javier Martinez Canillas
2015-10-07  5:46   ` Dan Carpenter
2015-10-07  8:51     ` Javier Martinez Canillas
2015-10-07  9:22       ` Dan Carpenter

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=20151006225726.545f4ce5@heffalump.sk2.org \
    --to=steve@sk2.org \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-input@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).