hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/firewire/core-cdev.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Char device for device raw access
34 *
45 * 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.
196 */
207
218 #include <linux/bug.h>
....@@ -130,7 +117,7 @@
130117 struct descriptor_resource {
131118 struct client_resource resource;
132119 struct fw_descriptor descriptor;
133
- u32 data[0];
120
+ u32 data[];
134121 };
135122
136123 struct iso_resource {
....@@ -831,8 +818,10 @@
831818
832819 r = container_of(resource, struct inbound_transaction_resource,
833820 resource);
834
- if (is_fcp_request(r->request))
821
+ if (is_fcp_request(r->request)) {
822
+ kfree(r->data);
835823 goto out;
824
+ }
836825
837826 if (a->length != fw_get_response_length(r->request)) {
838827 ret = -EINVAL;
....@@ -1094,8 +1083,6 @@
10941083 return -EINVAL;
10951084
10961085 p = (struct fw_cdev_iso_packet __user *)u64_to_uptr(a->packets);
1097
- if (!access_ok(VERIFY_READ, p, a->size))
1098
- return -EFAULT;
10991086
11001087 end = (void __user *)p + a->size;
11011088 count = 0;
....@@ -1133,7 +1120,7 @@
11331120 &p->header[transmit_header_bytes / 4];
11341121 if (next > end)
11351122 return -EINVAL;
1136
- if (__copy_from_user
1123
+ if (copy_from_user
11371124 (u.packet.header, p->header, transmit_header_bytes))
11381125 return -EFAULT;
11391126 if (u.packet.skip && ctx->type == FW_ISO_CONTEXT_TRANSMIT &&
....@@ -1495,6 +1482,7 @@
14951482 {
14961483 struct outbound_phy_packet_event *e =
14971484 container_of(packet, struct outbound_phy_packet_event, p);
1485
+ struct client *e_client;
14981486
14991487 switch (status) {
15001488 /* expected: */
....@@ -1511,9 +1499,10 @@
15111499 }
15121500 e->phy_packet.data[0] = packet->timestamp;
15131501
1502
+ e_client = e->client;
15141503 queue_event(e->client, &e->event, &e->phy_packet,
15151504 sizeof(e->phy_packet) + e->phy_packet.length, NULL, 0);
1516
- client_put(e->client);
1505
+ client_put(e_client);
15171506 }
15181507
15191508 static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)
....@@ -1659,14 +1648,6 @@
16591648 return dispatch_ioctl(file->private_data, cmd, (void __user *)arg);
16601649 }
16611650
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
-
16701651 static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma)
16711652 {
16721653 struct client *client = file->private_data;
....@@ -1707,7 +1688,8 @@
17071688 if (ret < 0)
17081689 goto fail;
17091690
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);
17111693 if (ret < 0)
17121694 goto fail;
17131695
....@@ -1808,7 +1790,5 @@
18081790 .mmap = fw_device_op_mmap,
18091791 .release = fw_device_op_release,
18101792 .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,
18141794 };