Skip to content
Permalink
Browse files
usb: gadget: Fix memleak in gadgetfs_fill_super
usb_get_gadget_udc_name will alloc memory for CHIP
in "Enomem" branch. we should free it before error
returns to prevent memleak.

Fixes: 175f712 ("usb: gadget: provide interface for legacy gadgets to get UDC name")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
  • Loading branch information
Zhang Qilong authored and intel-lab-lkp committed Nov 16, 2020
1 parent 60ec609 commit 0dfab8598cb8b814fc17011d7a15ff463840e1dd
Showing 1 changed file with 3 additions and 0 deletions.
@@ -2039,6 +2039,9 @@ gadgetfs_fill_super (struct super_block *sb, struct fs_context *fc)
return 0;

Enomem:
free(CHIP);
CHIP = NULL;

return -ENOMEM;
}

0 comments on commit 0dfab85

Please sign in to comment.