[PATCH] pinctrl: aspeed: fix null dereference in debug

Andrew Jeffery andrew at aj.id.au
Wed Mar 2 11:09:04 AEDT 2022



On Wed, 2 Mar 2022, at 06:00, Weiguo Li wrote:
> "pdesc" is null checked, but already dereferenced ahead in debug.
> Swap their positions to avoid potential null dereference.
>
> Signed-off-by: Weiguo Li <liwg06 at foxmail.com>

Thanks.

Reviewed-by: Andrew Jeffery <andrew at aj.id.au>

> ---
>  drivers/pinctrl/aspeed/pinctrl-aspeed.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed.c 
> b/drivers/pinctrl/aspeed/pinctrl-aspeed.c
> index c94e24aadf92..83d47ff1cea8 100644
> --- a/drivers/pinctrl/aspeed/pinctrl-aspeed.c
> +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed.c
> @@ -236,11 +236,11 @@ int aspeed_pinmux_set_mux(struct pinctrl_dev 
> *pctldev, unsigned int function,
>  		const struct aspeed_sig_expr **funcs;
>  		const struct aspeed_sig_expr ***prios;
> 
> -		pr_debug("Muxing pin %s for %s\n", pdesc->name, pfunc->name);
> -
>  		if (!pdesc)
>  			return -EINVAL;
> 
> +		pr_debug("Muxing pin %s for %s\n", pdesc->name, pfunc->name);
> +
>  		prios = pdesc->prios;
> 
>  		if (!prios)
> -- 
> 2.25.1


More information about the Linux-aspeed mailing list