Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: vt/keyboard: simplify returns from vt_do_kbkeycode_ioctl()

Return immediately when something goes wrong in vt_do_kbkeycode_ioctl().
This makes the code flow more obvious.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://patch.msgid.link/20251119100140.830761-8-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
d139b31f bfb24564

+9 -9
+9 -9
drivers/tty/vt/keyboard.c
··· 1879 1879 return ret; 1880 1880 } 1881 1881 1882 - int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, 1883 - int perm) 1882 + int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, int perm) 1884 1883 { 1885 1884 struct kbkeycode tmp; 1886 - int kc = 0; 1885 + int kc; 1887 1886 1888 1887 if (copy_from_user(&tmp, user_kbkc, sizeof(struct kbkeycode))) 1889 1888 return -EFAULT; 1889 + 1890 1890 switch (cmd) { 1891 1891 case KDGETKEYCODE: 1892 1892 kc = getkeycode(tmp.scancode); 1893 - if (kc >= 0) 1894 - kc = put_user(kc, &user_kbkc->keycode); 1895 - break; 1893 + if (kc < 0) 1894 + return kc; 1895 + return put_user(kc, &user_kbkc->keycode); 1896 1896 case KDSETKEYCODE: 1897 1897 if (!perm) 1898 1898 return -EPERM; 1899 - kc = setkeycode(tmp.scancode, tmp.keycode); 1900 - break; 1899 + return setkeycode(tmp.scancode, tmp.keycode); 1901 1900 } 1902 - return kc; 1901 + 1902 + return 0; 1903 1903 } 1904 1904 1905 1905 static unsigned short vt_kdgkbent(unsigned char kbdmode, unsigned char idx,