mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-20 06:06:23 +00:00
scst_disk: Fix use of uninitialized variable
This patch fixes the following Coverity complaint:
CID 307352 (#1 of 1): Uninitialized pointer read (UNINIT)
uninit_use_in_call: Using uninitialized value arg when calling
kfree.
Fixes: 7ba5b11f0a ("scst_disk: Add cluster SCSI sync state mode
support to dev_disk")
This commit is contained in:
@@ -633,34 +633,42 @@ static ssize_t disk_sysfs_cluster_mode_store(struct kobject *kobj,
|
||||
struct scst_device *dev = container_of(kobj, struct scst_device,
|
||||
dev_kobj);
|
||||
struct scst_sysfs_work_item *work;
|
||||
char *arg;
|
||||
char *arg = NULL;
|
||||
int res;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
res = -ENOMEM;
|
||||
/* Must have a serial number to enable cluster_mode */
|
||||
if (count && !dev->dh_priv)
|
||||
if (count && !dev->dh_priv) {
|
||||
res = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
arg = kasprintf(GFP_KERNEL, "%.*s", (int)count, buf);
|
||||
if (!arg)
|
||||
if (!arg) {
|
||||
res = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
res = scst_alloc_sysfs_work(disk_sysfs_process_cluster_mode_store,
|
||||
false, &work);
|
||||
if (res)
|
||||
goto out;
|
||||
|
||||
work->dev = dev;
|
||||
swap(work->buf, arg);
|
||||
kobject_get(&dev->dev_kobj);
|
||||
|
||||
res = scst_sysfs_queue_wait_work(work);
|
||||
if (res)
|
||||
goto out;
|
||||
|
||||
res = count;
|
||||
|
||||
out:
|
||||
kfree(arg);
|
||||
TRACE_EXIT_RES(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user