[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20231118134244.GB30289@breakpoint.cc>
Date: Sat, 18 Nov 2023 14:42:44 +0100
From: Florian Westphal <fw@...len.de>
To: Kamil Duljas <kamil.duljas@...il.com>
Cc: Florian Westphal <fw@...len.de>, Jakub Kicinski <kuba@...nel.org>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Jiri Pirko <jiri@...nulli.us>,
Johannes Berg <johannes@...solutions.net>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] genetlink: Prevent memory leak when krealloc fail
Kamil Duljas <kamil.duljas@...il.com> wrote:
> Yes, you're right. I did not think about it. So if we have a static
> pointer that may be resued, should not restore the pointer as at the
> beginning?
> static unsigned long *mc_groups = &mc_group_start;
>
> At this moment we don't know how much memory is allocated. What do you
> think about this?
We do: mc_groups_longs.
> > new_groups = krealloc(mc_groups, nlen,
> > GFP_KERNEL);
> > - if (!new_groups)
> > + if (!new_groups) {
> > + kfree(mc_groups);
> > + mc_groups = &mc_group_start;
> > return -ENOMEM;
> > + }
Seems wrong to shrink when we can't grow. Whats the point?
Powered by blists - more mailing lists