Skip to content

Commit

Permalink
ALSA: hdsp: Make the firmware loading ioctl a bit more readable
Browse files Browse the repository at this point in the history
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: d63e63d ("ALSA: hdsp: Make uapi/hdsp.h compilable again")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Feb 2, 2020
1 parent 81b4509 commit 112e3f5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sound/pci/rme9652/hdsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4802,7 +4802,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
break;
}
case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
struct hdsp_firmware __user *firmware;
struct hdsp_firmware firmware;
u32 __user *firmware_data;
int err;

Expand All @@ -4815,10 +4815,9 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne

dev_info(hdsp->card->dev,
"initializing firmware upload\n");
firmware = (struct hdsp_firmware __user *)argp;

if (get_user(firmware_data, (__force void __user **)&firmware->firmware_data))
if (copy_from_user(&firmware, argp, sizeof(firmware)))
return -EFAULT;
firmware_data = (u32 __user *)firmware.firmware_data;

if (hdsp_check_for_iobox (hdsp))
return -EIO;
Expand Down

0 comments on commit 112e3f5

Please sign in to comment.