Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a9d3554 authored by Linus Torvalds's avatar Linus Torvalds Committed by Lee Jones
Browse files

UPSTREAM: proc: avoid integer type confusion in get_proc_long



commit e6cfaf34be9fcd1a8285a294e18986bfc41a409c upstream.

proc_get_long() is passed a size_t, but then assigns it to an 'int'
variable for the length.  Let's not do that, even if our IO paths are
limited to MAX_RW_COUNT (exactly because of these kinds of type errors).

So do the proper test in the rigth type.

Bug: 261488859
Reported-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: I75a06fe777c638b82ef3fbd1346e985065ab17f2
Signed-off-by: default avatarLee Jones <joneslee@google.com>
parent cffda199
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2241,13 +2241,12 @@ static int proc_get_long(char **buf, size_t *size,
			  unsigned long *val, bool *neg,
			  const char *perm_tr, unsigned perm_tr_len, char *tr)
{
	int len;
	char *p, tmp[TMPBUFLEN];
	ssize_t len = *size;

	if (!*size)
	if (len <= 0)
		return -EINVAL;

	len = *size;
	if (len > TMPBUFLEN - 1)
		len = TMPBUFLEN - 1;