On Fri, Jun 05, 2015 at 06:43:33PM +0200, Julia Lawall wrote: >On Sat, 6 Jun 2015, Firo Yang wrote: > >> In error path, we forgot to free fw_work alloced by kzalloc. >> This will make a memory leak. So just free it before return. >> >> Signed-off-by: Firo Yang <firogm@xxxxxxxxx> >> --- >> drivers/base/firmware_class.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c >> index 8c3aa3c..9c42883 100644 >> --- a/drivers/base/firmware_class.c >> +++ b/drivers/base/firmware_class.c >> @@ -1307,8 +1307,10 @@ request_firmware_nowait( >> >> fw_work->module = module; >> fw_work->name = kstrdup_const(name, gfp); >> - if (!fw_work->name) >> + if (!fw_work->name) { >> + kfree(fw_work); >> return -ENOMEM; >> + } > >Maybe it would be better to unify the error handling code at the end of >the function, if things are being forgotten. Thanks Julia! I will reconstruct the code. Firo > >julia > >> fw_work->device = device; >> fw_work->context = context; >> fw_work->cont = cont; >> -- >> 2.4.2 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in >> the body of a message to majordomo@xxxxxxxxxxxxxxx >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> -- -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html