Commit 0f8fd43c42f2cc249943be76a4db0d058c16b6dc
Committed by
Greg Kroah-Hartman
1 parent
0889551267
Exists in
master
and in
6 other branches
USB: gadget: midi: memory leak in f_midi_bind_config()
There is a small memory leak on the error paths. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
drivers/usb/gadget/f_midi.c
... | ... | @@ -951,7 +951,7 @@ |
951 | 951 | struct gmidi_in_port *port = kzalloc(sizeof(*port), GFP_KERNEL); |
952 | 952 | if (!port) { |
953 | 953 | status = -ENOMEM; |
954 | - goto fail; | |
954 | + goto setup_fail; | |
955 | 955 | } |
956 | 956 | |
957 | 957 | port->midi = midi; |
... | ... | @@ -989,6 +989,8 @@ |
989 | 989 | return 0; |
990 | 990 | |
991 | 991 | setup_fail: |
992 | + for (--i; i >= 0; i--) | |
993 | + kfree(midi->in_port[i]); | |
992 | 994 | kfree(midi); |
993 | 995 | fail: |
994 | 996 | return status; |