[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.21.1906041613480.16030@pobox.suse.cz>
Date: Tue, 4 Jun 2019 16:15:39 +0200 (CEST)
From: Miroslav Benes <mbenes@...e.cz>
To: Yuehaibing <yuehaibing@...wei.com>
cc: jeyu@...nel.org, gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] kernel/module: Fix mem leak in
module_add_modinfo_attrs
> >> -static void module_remove_modinfo_attrs(struct module *mod)
> >> +static void module_remove_modinfo_attrs(struct module *mod, int end)
> >> {
> >> struct module_attribute *attr;
> >> int i;
> >>
> >> for (i = 0; (attr = &mod->modinfo_attrs[i]); i++) {
> >> + if (end >= 0 && i > end)
> >> + break;
> >
> > If end == 0, you break the loop without calling sysfs_remove_file(), which
> > is a bug if you called module_remove_modinfo_attrs(mod, 0).
>
> If end == 0 and i == 0, if statement is false, it won't break the loop.
Eh, you're right of course.
Miroslav
Powered by blists - more mailing lists