summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2018-08-06 18:10:40 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2018-08-08 14:23:47 -0400
commit100294cee9a98bfd4d6cb2d1c8a8aef0e959b0c4 (patch)
treebbcc4b62c252897be5c4fdb6b8f64e1ce10b1361
parent17a4ed5545c5599852a5d75c5fb2c8e597943f99 (diff)
Input: do not use WARN() in input_alloc_absinfo()
Some of fuzzers set panic_on_warn=1 so that they can handle WARN()ings the same way they handle full-blown kernel crashes. We used WARN() in input_alloc_absinfo() to get a better idea where memory allocation failed, but since then kmalloc() and friends started dumping call stack on memory allocation failures anyway, so we are not getting anything extra from WARN(). Because of the above, let's replace WARN with dev_err(). We use dev_err() instead of simply removing message and relying on kcalloc() to give us stack dump so that we'd know the instance of hardware device to which we were trying to attach input device. Reported-by: Dmitry Vyukov <dvyukov@google.com> Acked-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/input.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 6365c1958264..3304aaaffe87 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -480,11 +480,19 @@ EXPORT_SYMBOL(input_inject_event);
480 */ 480 */
481void input_alloc_absinfo(struct input_dev *dev) 481void input_alloc_absinfo(struct input_dev *dev)
482{ 482{
483 if (!dev->absinfo) 483 if (dev->absinfo)
484 dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo), 484 return;
485 GFP_KERNEL);
486 485
487 WARN(!dev->absinfo, "%s(): kcalloc() failed?\n", __func__); 486 dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo), GFP_KERNEL);
487 if (!dev->absinfo) {
488 dev_err(dev->dev.parent ?: &dev->dev,
489 "%s: unable to allocate memory\n", __func__);
490 /*
491 * We will handle this allocation failure in
492 * input_register_device() when we refuse to register input
493 * device with ABS bits but without absinfo.
494 */
495 }
488} 496}
489EXPORT_SYMBOL(input_alloc_absinfo); 497EXPORT_SYMBOL(input_alloc_absinfo);
490 498