> > On 20-11-16 20:17:10, Zhang Qilong wrote: > > usb_get_gadget_udc_name will alloc memory for CHIP in "Enomem" branch. > > we should free it before error returns to prevent memleak. > > > > Fixes: 175f712119c57 ("usb: gadget: provide interface for legacy > > gadgets to get UDC name") > > Reported-by: Hulk Robot <hulkci@xxxxxxxxxx> > > Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx> > > --- > > drivers/usb/gadget/legacy/inode.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/usb/gadget/legacy/inode.c > > b/drivers/usb/gadget/legacy/inode.c > > index 1b430b36d0a6..3cefc27be098 100644 > > --- a/drivers/usb/gadget/legacy/inode.c > > +++ b/drivers/usb/gadget/legacy/inode.c > > @@ -2039,6 +2039,9 @@ gadgetfs_fill_super (struct super_block *sb, struct > fs_context *fc) > > return 0; > > > > Enomem: > > + free(CHIP); > > + CHIP = NULL; > > + > > return -ENOMEM; > > } > > It seems the dev_new also allocate the memory, would you please change it > too, also, create a new goto entry for it. If gadgetfs_create_file fails, the dev_new will be freed in put_dev. Thanks, Zhang > -- > > Thanks, > Peter Chen