[U-Boot] [PATCH 1/1] ubifs: no NULL check needed before free
Heinrich Schuchardt
xypron.glpk at gmx.de
Tue Nov 21 11:51:35 UTC 2017
On 11/21/2017 10:20 AM, Alex Sadovsky wrote:
> Hi Heinrich and Heiko,
>
> do you see anything strange in this code (it was more obvious before
> the patch but it can still be spotted)? I should say that it's too
> late to check for "file != NULL" after the "file->private_data"
> dereference. Maybe it should look like this:
> if (file)
> kfree(file->private_data);
> free(file);
> shouldn't it?
Thanks for spotting this.
Probably we should fix it here:
if (!file || !dentry || !dir) {
printf("%s: Error, no memory for malloc!\n", __func__);
err = -ENOMEM;
goto out;
}
Why should we first print
printf("%s: Error, no memory for malloc!\n", __func__);
and then
dbg_gen("cannot find next direntry, error %d", err);
Instead we should immediately return.
Regards
Heinrich
More information about the U-Boot
mailing list