Add check to prevent read() in case open() has failed.
Coverity CID:
1595922: Error handling issues (NEGATIVE_RETURNS)
Fixes: 6f52ef3 ("get_cmdline_val: search for entire name, not just suffix")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
{
char line[CMDLINE_SIZE + 1], *c, *sptr;
int i, fd = open("/proc/cmdline", O_RDONLY);
- ssize_t r = read(fd, line, sizeof(line) - 1);
+ ssize_t r;
+
+ if (fd < 0)
+ return NULL;
+
+ r = read(fd, line, sizeof(line) - 1);
close(fd);
if (r <= 0)