blobfs: Add the return value check for calling cache_append_buffer
Reason: We need to detect this issue. Otherwise, it will cause null pointer issue later Change-Id: I4d9aec0570e0b46274ebf3b9642b4727049a4a3b Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448594 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
11b38a585a
commit
b151999f06
@ -2142,19 +2142,19 @@ spdk_file_write(struct spdk_file *file, struct spdk_io_channel *_channel,
|
||||
pthread_spin_lock(&file->lock);
|
||||
file->open_for_writing = true;
|
||||
|
||||
if (file->last == NULL) {
|
||||
if (file->append_pos % CACHE_BUFFER_SIZE == 0) {
|
||||
cache_append_buffer(file);
|
||||
} else {
|
||||
int rc;
|
||||
if ((file->last == NULL) && (file->append_pos % CACHE_BUFFER_SIZE == 0)) {
|
||||
cache_append_buffer(file);
|
||||
}
|
||||
|
||||
file->append_pos += length;
|
||||
pthread_spin_unlock(&file->lock);
|
||||
rc = __send_rw_from_file(file, &channel->sem, payload,
|
||||
offset, length, false);
|
||||
sem_wait(&channel->sem);
|
||||
return rc;
|
||||
}
|
||||
if (file->last == NULL) {
|
||||
int rc;
|
||||
|
||||
file->append_pos += length;
|
||||
pthread_spin_unlock(&file->lock);
|
||||
rc = __send_rw_from_file(file, &channel->sem, payload,
|
||||
offset, length, false);
|
||||
sem_wait(&channel->sem);
|
||||
return rc;
|
||||
}
|
||||
|
||||
blob_size = __file_get_blob_size(file);
|
||||
|
Loading…
Reference in New Issue
Block a user