diff options
author | Sean Anderson <seanga2@gmail.com> | 2021-05-15 14:13:54 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-05-26 17:26:07 -0400 |
commit | 26de4296cc20bb45eb40560b4a4a98fa90a16a28 (patch) | |
tree | de1445c07026f8560505516b883685397fbbcb34 /disk | |
parent | 1e7879045f6c20f68ce2c6fcce7ec187e8844b51 (diff) | |
download | u-boot-26de4296cc20bb45eb40560b4a4a98fa90a16a28.tar.gz u-boot-26de4296cc20bb45eb40560b4a4a98fa90a16a28.tar.bz2 u-boot-26de4296cc20bb45eb40560b4a4a98fa90a16a28.zip |
part: Add check for NULL dev_part_str
Some callers (e.g. cmd/fs.c) of fs_set_blk_dev may use a NULL dev_part_str.
While blk_get_device_part_str handles this fine,
part_get_info_by_dev_and_name does not. This fixes commands crashing when
implicitly using bootdevice.
The unit test has also been updated to set bootdevice to a known value and
to restore it after we are done.
Fixes: 7194527b6a ("cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions")
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/disk/part.c b/disk/part.c index 5e7e59cf25..086da84b7f 100644 --- a/disk/part.c +++ b/disk/part.c @@ -714,7 +714,11 @@ static int part_get_info_by_dev_and_name(const char *dev_iface, int ret; /* Separate device and partition name specification */ - part_str = strchr(dev_part_str, '#'); + if (dev_part_str) + part_str = strchr(dev_part_str, '#'); + else + part_str = NULL; + if (part_str) { dup_str = strdup(dev_part_str); dup_str[part_str - dev_part_str] = 0; |