Skip to contentSkip to conversation

ALSA: hdsp: fix a test for copy_to_user() failure

PATCH Applied Dan Carpenter 2 participants 2 messages Jun 22, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hdsp: fix a test for copy_to_user() failure

The copy_to_user() function returns the number of bytes remaining to be copied. It doesn't return negatives.

Fixes 66c8f75919dd ("ALSA: hdsp: Fix assignment in if condition")
---
 sound/pci/rme9652/hdsp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
sound/pci/rme9652/hdsp.c +2 -3
index e3e4fabf4abf..8457a4bbc3df 100644
@@ -4877,9 +4877,8 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
 		memset(&hdsp_version, 0, sizeof(hdsp_version));
 		hdsp_version.io_type = hdsp->io_type;
 		hdsp_version.firmware_rev = hdsp->firmware_rev;
-		err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version));
-		if (err < 0)
-		    	return -EFAULT;
+		if (copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))
+			return -EFAULT;
 		break;
 	}
 	case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
Signature · 1 line
2.30.2
Applied
#1 lore raw
Quoted 6 lines · Dan Carpenter

The copy_to_user() function returns the number of bytes remaining to be copied. It doesn't return negatives.

Fixes 66c8f75919dd ("ALSA: hdsp: Fix assignment in if condition")

Thanks, applied.

Takashi