[PATCH v8 13/30] powerpc: Add a probe_user_read_inst() function

Michael Ellerman mpe at ellerman.id.au
Wed May 13 22:52:42 AEST 2020


Jordan Niethe <jniethe5 at gmail.com> writes:
> diff --git a/arch/powerpc/lib/inst.c b/arch/powerpc/lib/inst.c
> new file mode 100644
> index 000000000000..eaf786afad2b
> --- /dev/null
> +++ b/arch/powerpc/lib/inst.c
> @@ -0,0 +1,18 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + *  Copyright 2020, IBM Corporation.
> + */
> +
> +#include <linux/uaccess.h>
> +#include <asm/inst.h>
> +
> +int probe_user_read_inst(struct ppc_inst *inst,
> +			 struct ppc_inst *nip)
> +{
> +	unsigned int val;
> +	int err;
> +
> +	err = probe_user_read(&val, nip, sizeof(val));
> +	*inst = ppc_inst(val);

We shouldn't be storing to *inst if the read failed?

I changed it to:

+	if (!err)
+		*inst = ppc_inst(val);
+

Similarly for probe_kernel_read_inst().

cheers


More information about the Linuxppc-dev mailing list