Commit 112e3f5a authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hdsp: Make the firmware loading ioctl a bit more readable

The firmware loading ioctl that is implemented for hdsp hwdep device
takes the reference of the address pointer, hence the current code is
rather confusing.  Also, due to the recent change in uapi header,
sparse also complains about the cast.

This patch tries to improve the readability by converting the
straightforward copy_from_user of the whole struct (which contains
only the pointer).

Fixes: d63e63d4 ("ALSA: hdsp: Make uapi/hdsp.h compilable again")
Link: https://lore.kernel.org/r/20200202090724.18232-2-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 81b45090
...@@ -4802,7 +4802,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne ...@@ -4802,7 +4802,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
break; break;
} }
case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: { case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
struct hdsp_firmware __user *firmware; struct hdsp_firmware firmware;
u32 __user *firmware_data; u32 __user *firmware_data;
int err; int err;
...@@ -4815,10 +4815,9 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne ...@@ -4815,10 +4815,9 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
dev_info(hdsp->card->dev, dev_info(hdsp->card->dev,
"initializing firmware upload\n"); "initializing firmware upload\n");
firmware = (struct hdsp_firmware __user *)argp; if (copy_from_user(&firmware, argp, sizeof(firmware)))
if (get_user(firmware_data, (__force void __user **)&firmware->firmware_data))
return -EFAULT; return -EFAULT;
firmware_data = (u32 __user *)firmware.firmware_data;
if (hdsp_check_for_iobox (hdsp)) if (hdsp_check_for_iobox (hdsp))
return -EIO; return -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment