On Mon, Jun 1, 2009 at 1:38 AM, Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> wrote: > On Sunday 31 May 2009 07:29:08 Eric Miao wrote: >> On Sun, May 31, 2009 at 10:20 PM, Russell King - ARM Linux >> >> <linux@xxxxxxxxxxxxxxxx> wrote: >> > On Sun, May 31, 2009 at 10:12:25PM +0800, Eric Miao wrote: >> >> +static void __devinit build_keycodes(struct matrix_keypad *keypad) >> >> +{ >> >> + struct matrix_keypad_platform_data *pdata = keypad->pdata; >> >> + struct input_dev *input_dev = keypad->input_dev; >> >> + uint32_t *key; >> >> + int i; >> >> + >> >> + keypad->keycodes = kzalloc(MATRIX_MAX_KEYS * sizeof(int), >> >> GFP_KERNEL); >> > >> > This doesn't check for failure... >> >> Oops, updated (together with the release) as below: > > Eric, could you please send me this patch as a diff to the original > one you sent? > Sorry, I used 'git commit --amend' for this and I'm not sure if I can recover the diff. I'll paste the changed part here instead: + keypad->keycodes = kzalloc(MATRIX_MAX_KEYS * sizeof(int), GFP_KERNEL); + if (keypad->keycodes == NULL) + return -ENOMEM; + + key = &pdata->key_map[0]; + for (i = 0; i < pdata->key_map_size; i++, key++) { + keypad->keycodes[KEY_ROWCOL(*key)] = KEY_VAL(*key); + set_bit(KEY_VAL(*key), input_dev->keybit); + } + return 0; returns something in 'build_keycodes()'. + err = build_keycodes(keypad); + if (err) + goto err_free_input; + ... + +err_unregister: + input_unregister_device(input_dev); +err_free_keycodes: + kfree(keypad->keycodes); +err_free_input: + input_free_device(input_dev); +err_free_keypad: + kfree(keypad); + return err; add one more exiting path when build_keycodes() failed + + input_unregister_device(keypad->input_dev); + kfree(keypad->keycodes); + kfree(keypad); + return 0; kfree(keypad->keycodes) in matrix_keypad_remove() -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html