linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: Input: joydev - validate axis/button maps before clobbering current ones
@ 2015-10-06 18:51 Dan Carpenter
  2015-10-06 20:57 ` Stephen Kitt
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Carpenter @ 2015-10-06 18:51 UTC (permalink / raw)
  To: steve; +Cc: linux-input

Hello Stephen Kitt,

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.

   451          }
   452  
   453          for (i = 0; i < joydev->nabs; i++) {
   454                  if (abspam[i] > ABS_MAX) {
   455                          retval = -EINVAL;
   456                          goto out;
   457                  }
   458          }
   459  
   460          memcpy(joydev->abspam, abspam, len);
   461  
   462          for (i = 0; i < joydev->nabs; i++)
   463                  joydev->absmap[joydev->abspam[i]] = i;
   464  
   465   out:
   466          kfree(abspam);
   467          return retval;
   468  }

regards,
dan carpenter

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

end of thread, other threads:[~2015-10-07  9:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-06 18:51 Input: joydev - validate axis/button maps before clobbering current ones Dan Carpenter
2015-10-06 20:57 ` Stephen Kitt
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

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