.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Char device for device raw access |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program; if not, write to the Free Software Foundation, |
---|
18 | | - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | 6 | */ |
---|
20 | 7 | |
---|
21 | 8 | #include <linux/bug.h> |
---|
.. | .. |
---|
130 | 117 | struct descriptor_resource { |
---|
131 | 118 | struct client_resource resource; |
---|
132 | 119 | struct fw_descriptor descriptor; |
---|
133 | | - u32 data[0]; |
---|
| 120 | + u32 data[]; |
---|
134 | 121 | }; |
---|
135 | 122 | |
---|
136 | 123 | struct iso_resource { |
---|
.. | .. |
---|
831 | 818 | |
---|
832 | 819 | r = container_of(resource, struct inbound_transaction_resource, |
---|
833 | 820 | resource); |
---|
834 | | - if (is_fcp_request(r->request)) |
---|
| 821 | + if (is_fcp_request(r->request)) { |
---|
| 822 | + kfree(r->data); |
---|
835 | 823 | goto out; |
---|
| 824 | + } |
---|
836 | 825 | |
---|
837 | 826 | if (a->length != fw_get_response_length(r->request)) { |
---|
838 | 827 | ret = -EINVAL; |
---|
.. | .. |
---|
1094 | 1083 | return -EINVAL; |
---|
1095 | 1084 | |
---|
1096 | 1085 | p = (struct fw_cdev_iso_packet __user *)u64_to_uptr(a->packets); |
---|
1097 | | - if (!access_ok(VERIFY_READ, p, a->size)) |
---|
1098 | | - return -EFAULT; |
---|
1099 | 1086 | |
---|
1100 | 1087 | end = (void __user *)p + a->size; |
---|
1101 | 1088 | count = 0; |
---|
.. | .. |
---|
1133 | 1120 | &p->header[transmit_header_bytes / 4]; |
---|
1134 | 1121 | if (next > end) |
---|
1135 | 1122 | return -EINVAL; |
---|
1136 | | - if (__copy_from_user |
---|
| 1123 | + if (copy_from_user |
---|
1137 | 1124 | (u.packet.header, p->header, transmit_header_bytes)) |
---|
1138 | 1125 | return -EFAULT; |
---|
1139 | 1126 | if (u.packet.skip && ctx->type == FW_ISO_CONTEXT_TRANSMIT && |
---|
.. | .. |
---|
1495 | 1482 | { |
---|
1496 | 1483 | struct outbound_phy_packet_event *e = |
---|
1497 | 1484 | container_of(packet, struct outbound_phy_packet_event, p); |
---|
| 1485 | + struct client *e_client; |
---|
1498 | 1486 | |
---|
1499 | 1487 | switch (status) { |
---|
1500 | 1488 | /* expected: */ |
---|
.. | .. |
---|
1511 | 1499 | } |
---|
1512 | 1500 | e->phy_packet.data[0] = packet->timestamp; |
---|
1513 | 1501 | |
---|
| 1502 | + e_client = e->client; |
---|
1514 | 1503 | queue_event(e->client, &e->event, &e->phy_packet, |
---|
1515 | 1504 | sizeof(e->phy_packet) + e->phy_packet.length, NULL, 0); |
---|
1516 | | - client_put(e->client); |
---|
| 1505 | + client_put(e_client); |
---|
1517 | 1506 | } |
---|
1518 | 1507 | |
---|
1519 | 1508 | static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg) |
---|
.. | .. |
---|
1659 | 1648 | return dispatch_ioctl(file->private_data, cmd, (void __user *)arg); |
---|
1660 | 1649 | } |
---|
1661 | 1650 | |
---|
1662 | | -#ifdef CONFIG_COMPAT |
---|
1663 | | -static long fw_device_op_compat_ioctl(struct file *file, |
---|
1664 | | - unsigned int cmd, unsigned long arg) |
---|
1665 | | -{ |
---|
1666 | | - return dispatch_ioctl(file->private_data, cmd, compat_ptr(arg)); |
---|
1667 | | -} |
---|
1668 | | -#endif |
---|
1669 | | - |
---|
1670 | 1651 | static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) |
---|
1671 | 1652 | { |
---|
1672 | 1653 | struct client *client = file->private_data; |
---|
.. | .. |
---|
1707 | 1688 | if (ret < 0) |
---|
1708 | 1689 | goto fail; |
---|
1709 | 1690 | |
---|
1710 | | - ret = fw_iso_buffer_map_vma(&client->buffer, vma); |
---|
| 1691 | + ret = vm_map_pages_zero(vma, client->buffer.pages, |
---|
| 1692 | + client->buffer.page_count); |
---|
1711 | 1693 | if (ret < 0) |
---|
1712 | 1694 | goto fail; |
---|
1713 | 1695 | |
---|
.. | .. |
---|
1808 | 1790 | .mmap = fw_device_op_mmap, |
---|
1809 | 1791 | .release = fw_device_op_release, |
---|
1810 | 1792 | .poll = fw_device_op_poll, |
---|
1811 | | -#ifdef CONFIG_COMPAT |
---|
1812 | | - .compat_ioctl = fw_device_op_compat_ioctl, |
---|
1813 | | -#endif |
---|
| 1793 | + .compat_ioctl = compat_ptr_ioctl, |
---|
1814 | 1794 | }; |
---|