Skip to content

Commit 8d38d74

Browse files
Chen Gongaegl
authored andcommitted
pstore: fix one type of return value in pstore
the return type of function _read_ in pstore is size_t, but in the callback function of _read_, the logic doesn't consider it too much, which means if negative value (assuming error here) is returned, it will be converted to positive because of type casting. ssize_t is enough for this function. Signed-off-by: Chen Gong <gong.chen@linux.intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent 693d92a commit 8d38d74

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎drivers/acpi/apei/erst.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ static int erst_check_table(struct acpi_table_erst *erst_tab)
929929
return 0;
930930
}
931931

932-
static size_t erst_reader(u64 *id, enum pstore_type_id *type,
932+
static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
933933
struct timespec *time);
934934
static u64 erst_writer(enum pstore_type_id type, size_t size);
935935

@@ -957,7 +957,7 @@ struct cper_pstore_record {
957957
char data[];
958958
} __packed;
959959

960-
static size_t erst_reader(u64 *id, enum pstore_type_id *type,
960+
static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
961961
struct timespec *time)
962962
{
963963
int rc;

‎fs/pstore/platform.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ EXPORT_SYMBOL_GPL(pstore_register);
152152
void pstore_get_records(void)
153153
{
154154
struct pstore_info *psi = psinfo;
155-
size_t size;
155+
ssize_t size;
156156
u64 id;
157157
enum pstore_type_id type;
158158
struct timespec time;
@@ -163,7 +163,7 @@ void pstore_get_records(void)
163163

164164
mutex_lock(&psinfo->buf_mutex);
165165
while ((size = psi->read(&id, &type, &time)) > 0) {
166-
if (pstore_mkfile(type, psi->name, id, psi->buf, size,
166+
if (pstore_mkfile(type, psi->name, id, psi->buf, (size_t)size,
167167
time, psi->erase))
168168
failed++;
169169
}

‎include/linux/pstore.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct pstore_info {
3535
struct mutex buf_mutex; /* serialize access to 'buf' */
3636
char *buf;
3737
size_t bufsize;
38-
size_t (*read)(u64 *id, enum pstore_type_id *type,
38+
ssize_t (*read)(u64 *id, enum pstore_type_id *type,
3939
struct timespec *time);
4040
u64 (*write)(enum pstore_type_id type, size_t size);
4141
int (*erase)(u64 id);

0 commit comments

Comments
 (0)