Skip to content

Commit cf55902

Browse files
Dan Carpentergregkh
authored andcommitted
staging: android: ion: Fix error handling in ion_query_heaps()
If the copy_to_user() fails we should unlock and return directly without updating "cnt". Also the return value should be -EFAULT instead of the number of bytes remaining. Fixes: 02b2380 ("staging: android: ion: Add ioctl to query available heaps") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8b77eb9 commit cf55902

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • drivers/staging/android/ion

drivers/staging/android/ion/ion.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,10 @@ int ion_query_heaps(struct ion_client *client, struct ion_heap_query *query)
11871187
hdata.type = heap->type;
11881188
hdata.heap_id = heap->id;
11891189

1190-
ret = copy_to_user(&buffer[cnt],
1191-
&hdata, sizeof(hdata));
1190+
if (copy_to_user(&buffer[cnt], &hdata, sizeof(hdata))) {
1191+
ret = -EFAULT;
1192+
goto out;
1193+
}
11921194

11931195
cnt++;
11941196
if (cnt >= max_cnt)

0 commit comments

Comments
 (0)