Просмотр исходного кода

spu-kernel: spcom: spcom_ioctl_handle_get_message fix NULL pointer channel

This change fixes NULL pointer dereference for the cases when channel name
invalid is invalid: wrong channel name or usage control channel device as
spcom channel to receive message.

Change-Id: I6294d82906f093e026af62f3246ad3e872e5aa98
Signed-off-by: rakegand <[email protected]>
rakegand 1 год назад
Родитель
Сommit
0112e5abe4
1 измененных файлов с 3 добавлено и 5 удалено
  1. 3 5
      drivers/spcom.c

+ 3 - 5
drivers/spcom.c

@@ -2911,15 +2911,13 @@ static int spcom_ioctl_handle_get_message(struct spcom_ioctl_message *arg, void
 	ch_name = arg->ch_name;
 	if (!is_valid_ch_name(ch_name)) {
 		spcom_pr_err("invalid channel name\n");
-		ret = -EINVAL;
-		goto get_message_out;
+		return -EINVAL;
 	}
 
 	/* DEVICE_NAME name is reserved for control channel */
 	if (is_control_channel_name(ch_name)) {
 		spcom_pr_err("cannot send message on management channel %s\n", ch_name);
-		ret = -EFAULT;
-		goto get_message_out;
+		return -EFAULT;
 	}
 
 	ch = spcom_find_channel_by_name(ch_name);
@@ -2995,7 +2993,7 @@ static int spcom_ioctl_handle_get_message(struct spcom_ioctl_message *arg, void
 
 get_message_out:
 
-	if (ch && ch->active_pid == current_pid()) {
+	if (ch->active_pid == current_pid()) {
 		ch->active_pid = 0;
 		mutex_unlock(&ch->shared_sync_lock);
 	}