Input: libps2 - warn instead of oopsing when passed bad arguments
[firefly-linux-kernel-4.4.55.git] / drivers / input / serio / libps2.c
index 79c97f94bcbd5e9bcc31168020c3b7f1f0c32106..ed202f2f251aa76eeb3b680186a7baa7ddefaa7a 100644 (file)
@@ -177,7 +177,12 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
                return -1;
        }
 
-       mutex_lock(&ps2dev->cmd_mutex);
+       if (send && !param) {
+               WARN_ON(1);
+               return -1;
+       }
+
+       mutex_lock_nested(&ps2dev->cmd_mutex, SINGLE_DEPTH_NESTING);
 
        serio_pause_rx(ps2dev->serio);
        ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;