If __read_nocancel fails or overflows the buffer, the function returned
without closing the /sys/kernel/mm/transparent_hugepage/enabled fd.
Found while investigating BZ #34083.
Signed-off-by: Shamil Abdulaev <ashamil435@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
char str[sizeof(mode_always)];
ssize_t s = __read_nocancel (fd, str, sizeof (str));
+ __close_nocancel (fd);
if (s >= sizeof str || s < 0)
return thp_mode_not_supported;
str[s] = '\0';
- __close_nocancel (fd);
if (s == sizeof (mode_always) - 1)
{