[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wi=5p6s_BmPAg5EF8Joe5d-6iAjQq6-Le7+xf5Gq-ZTfw@mail.gmail.com>
Date: Tue, 10 Mar 2020 15:14:13 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Tejun Heo <tj@...nel.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Cgroups <cgroups@...r.kernel.org>
Subject: Re: [GIT PULL] cgroup fixes for v5.6-rc5
On Tue, Mar 10, 2020 at 7:41 AM Tejun Heo <tj@...nel.org> wrote:
>
> * Empty release_agent handling fix.
Pulled. However, I gagged a bit when I saw the code:
if (!pathbuf || !agentbuf || !strlen(agentbuf))
yeah, I really hope that the compiler is smart enough to just optimize
that, but we shouldn't assume that the compiler is that smart.
The proper way to test for "empty string" is to just check the first
character for NUL:
if (!pathbuf || !agentbuf || !*agentbuf)
which doesn't require the compiler to have a pattern for "oh, I can
test for a zero strlen without actually calling strlen".
Also, wouldn't it be nice to test for the empty string before you even
bother to kstrdup() it? Even before you
Finally, shouldn't we technically hold the release_agent_path_lock
while looking at it?
Small details, and I've taken the pull, but the lack of locking does
seem to be an actual (if perhaps fairly theoretical) bug, no?
Linus
Powered by blists - more mailing lists