Skip to content

Commit 112e3f5

Browse files
committed
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: d63e63d ("ALSA: hdsp: Make uapi/hdsp.h compilable again") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 81b4509 commit 112e3f5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sound/pci/rme9652/hdsp.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4802,7 +4802,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
48024802
break;
48034803
}
48044804
case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: {
4805-
struct hdsp_firmware __user *firmware;
4805+
struct hdsp_firmware firmware;
48064806
u32 __user *firmware_data;
48074807
int err;
48084808

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

48164816
dev_info(hdsp->card->dev,
48174817
"initializing firmware upload\n");
4818-
firmware = (struct hdsp_firmware __user *)argp;
4819-
4820-
if (get_user(firmware_data, (__force void __user **)&firmware->firmware_data))
4818+
if (copy_from_user(&firmware, argp, sizeof(firmware)))
48214819
return -EFAULT;
4820+
firmware_data = (u32 __user *)firmware.firmware_data;
48224821

48234822
if (hdsp_check_for_iobox (hdsp))
48244823
return -EIO;

0 commit comments

Comments
 (0)