lib/sysfs: check if cxt->dir_path is NULL in sysfs_readlink()
cxt->dir_path could be NULL, for example, when sysfs_init() fails, check this before calling readlink()/readlink_at(). Cc: Karel Zak <kzak@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
This commit is contained in:
parent
95f9f3098e
commit
cffee0de0c
|
@ -220,6 +220,9 @@ static int sysfs_open(struct sysfs_cxt *cxt, const char *attr)
|
|||
ssize_t sysfs_readlink(struct sysfs_cxt *cxt, const char *attr,
|
||||
char *buf, size_t bufsiz)
|
||||
{
|
||||
if (!cxt->dir_path)
|
||||
return -1;
|
||||
|
||||
if (attr)
|
||||
return readlink_at(cxt->dir_fd, cxt->dir_path, attr, buf, bufsiz);
|
||||
|
||||
|
|
Loading…
Reference in New Issue