Skip to content

Commit

Permalink
lsblk: fix null pointer dereferences
Browse files Browse the repository at this point in the history
Both catched with -Wnull-dereference compiler option:

Signed-off-by: Sami Kerola <[email protected]>
  • Loading branch information
kerolasa committed Dec 10, 2018
1 parent 2859592 commit e361253
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion misc-utils/lsblk-devtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ int lsblk_device_is_last_parent(struct lsblk_device *dev, struct lsblk_device *p
struct lsblk_devdep *dp = list_last_entry(
&dev->parents,
struct lsblk_devdep, ls_parents);

if (!dp)
return 0;
return dp->parent == parent;
}

Expand Down
4 changes: 2 additions & 2 deletions misc-utils/lsblk.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,15 +747,15 @@ static char *device_get_data(
case COL_OWNER:
{
struct stat *st = device_get_stat(dev);
struct passwd *pw = st ? NULL : getpwuid(st->st_uid);
struct passwd *pw = st ? getpwuid(st->st_uid) : NULL;
if (pw)
str = xstrdup(pw->pw_name);
break;
}
case COL_GROUP:
{
struct stat *st = device_get_stat(dev);
struct group *gr = st ? NULL : getgrgid(st->st_gid);
struct group *gr = st ? getgrgid(st->st_gid) : NULL;
if (gr)
str = xstrdup(gr->gr_name);
break;
Expand Down

0 comments on commit e361253

Please sign in to comment.