[alsa-devel] [PATCH 13/39] ALSA: seq: optimize client_info function to new design

Takashi Sakamoto o-takashi at sakamocchi.jp
Sun Aug 7 11:48:49 CEST 2016


In former commit, actual operations of each ioctl command get argument
in kernel space. Copying from/to user space is performed outside of
the function.

This commit optimizes to the new design.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 sound/core/seq/seq_clientmgr.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 10a2e43..3e7431e 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1209,25 +1209,19 @@ static void get_client_info(struct snd_seq_client *cptr,
 	memset(info->reserved, 0, sizeof(info->reserved));
 }
 
-static int seq_ioctl_get_client_info(struct snd_seq_client *client,
-				     void __user *arg)
+static int seq_ioctl_get_client_info(struct snd_seq_client *client, void *arg)
 {
+	struct snd_seq_client_info *client_info = arg;
 	struct snd_seq_client *cptr;
-	struct snd_seq_client_info client_info;
-
-	if (copy_from_user(&client_info, arg, sizeof(client_info)))
-		return -EFAULT;
 
 	/* requested client number */
-	cptr = snd_seq_client_use_ptr(client_info.client);
+	cptr = snd_seq_client_use_ptr(client_info->client);
 	if (cptr == NULL)
 		return -ENOENT;		/* don't change !!! */
 
-	get_client_info(cptr, &client_info);
+	get_client_info(cptr, client_info);
 	snd_seq_client_unlock(cptr);
 
-	if (copy_to_user(arg, &client_info, sizeof(client_info)))
-		return -EFAULT;
 	return 0;
 }
 
-- 
2.7.4



More information about the Alsa-devel mailing list