Skip to content

Commit 6898bf9

Browse files
committed
Add error checking on input device init
1 parent e391956 commit 6898bf9

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

xf86-input-mfndev/src/qubes.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ static void QubesUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
263263

264264
static int _qubes_init_kbd(DeviceIntPtr device)
265265
{
266-
InitKeyboardDeviceStruct(device, NULL, NULL, NULL);
266+
if (!InitKeyboardDeviceStruct(device, NULL, NULL, NULL))
267+
return BadAlloc;
267268
return Success;
268269
}
269270

@@ -485,14 +486,22 @@ static int QubesControl(DeviceIntPtr device, int what)
485486
InputInfoPtr pInfo = device->public.devicePrivate;
486487
QubesDevicePtr pQubes = pInfo->private;
487488
DeviceIntPtr master_kbd = NULL;
489+
int ret;
488490

489491
switch (what) {
490492
case DEVICE_INIT:
491493
device->public.on = FALSE;
492-
_qubes_init_buttons(device);
493-
_qubes_init_axes(device);
494-
_qubes_init_kbd(device);
495-
InitPtrFeedbackClassDeviceStruct(device, QubesPtrCtrlProc);
494+
ret = _qubes_init_buttons(device);
495+
if (ret != Success)
496+
return ret;
497+
ret = _qubes_init_axes(device);
498+
if (ret != Success)
499+
return ret;
500+
ret = _qubes_init_kbd(device);
501+
if (ret != Success)
502+
return ret;
503+
if (!InitPtrFeedbackClassDeviceStruct(device, QubesPtrCtrlProc))
504+
return BadAlloc;
496505
break;
497506

498507
/* Switch device on. Establish socket, start event delivery. */

0 commit comments

Comments
 (0)