diff options
author | Simon Glass <sjg@chromium.org> | 2023-01-17 20:47:43 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-01-24 02:11:40 +0300 |
commit | ca93d281717acb121960b50e6e9d7eebab3d950d (patch) | |
tree | 1e112c23b31392915f16f01dc183aeb52a31dc99 /drivers | |
parent | f0e358f07d75579b40eff8f723b280ab5d53d338 (diff) | |
download | u-boot-ca93d281717acb121960b50e6e9d7eebab3d950d.tar.xz |
scsi: Correct allocation of block-device name
This should be allocated so that it does not go out of scope. Fix this and
set the log category while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/scsi.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index a020a7da23..f7add08db8 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -4,6 +4,8 @@ * Denis Peter, MPL AG Switzerland */ +#define LOG_CATEGORY UCLASS_SCSI + #include <common.h> #include <blk.h> #include <bootstage.h> @@ -558,7 +560,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) struct udevice *bdev; struct blk_desc bd; struct blk_desc *bdesc; - char str[10]; + char str[10], *name; /* * detect the scsi driver to get information about its geometry (block @@ -574,12 +576,16 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) * block devices created */ snprintf(str, sizeof(str), "id%dlun%d", id, lun); - ret = blk_create_devicef(dev, "scsi_blk", str, UCLASS_SCSI, -1, + name = strdup(str); + if (!name) + return log_msg_ret("nam", -ENOMEM); + ret = blk_create_devicef(dev, "scsi_blk", name, UCLASS_SCSI, -1, bd.blksz, bd.lba, &bdev); if (ret) { debug("Can't create device\n"); return ret; } + device_set_name_alloced(bdev); bdesc = dev_get_uclass_plat(bdev); bdesc->target = id; |