Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7929436 authored by Geliang Tang's avatar Geliang Tang Committed by Mark Brown
Browse files

spi: spidev: use memdup_user



Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 76bf5694
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -324,7 +324,6 @@ static struct spi_ioc_transfer *
spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
		unsigned *n_ioc)
{
	struct spi_ioc_transfer	*ioc;
	u32	tmp;

	/* Check type, command number and direction */
@@ -341,14 +340,7 @@ spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
		return NULL;

	/* copy into scratch area */
	ioc = kmalloc(tmp, GFP_KERNEL);
	if (!ioc)
		return ERR_PTR(-ENOMEM);
	if (__copy_from_user(ioc, u_ioc, tmp)) {
		kfree(ioc);
		return ERR_PTR(-EFAULT);
	}
	return ioc;
	return memdup_user(u_ioc, tmp);
}

static long