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

Weiguo Li liwg06 at foxmail.com
Fri Mar 4 20:04:04 AEDT 2022


On Wed, 02 Mar 2022 15:12:24 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>
> Reviewed-by: Andrew Jeffery <andrew at aj.id.au>
> ---
> v2:
> * resend it after registering an account in aspeed patchwork
> ---
>  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)
> 

Moving Petr's review from previous version:

Reviewed-by: Petr Vorel <pvorel at suse.cz>

-Weiguo



More information about the Linux-aspeed mailing list