Linux-Aspeed Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@codeconstruct.com.au>
To: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>, joel@jms.id.au
Cc: linux-aspeed@lists.ozlabs.org
Subject: Re: [PATCH] soc: aspeed: deregister a misc device on error
Date: Mon, 09 Dec 2024 10:58:18 +1030	[thread overview]
Message-ID: <fff9f13e9839c086d566925c9066d885d46130ed.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20241207032504.1203334-1-joe@pf.is.s.u-tokyo.ac.jp>

Hi Joe,

On Sat, 2024-12-07 at 12:25 +0900, Joe Hattori wrote:
> The error path of aspeed_lpc_enable_snoop() does not deregister the
> misc
> device, which results in a memory leak. Therefore, add a
> misc_deregister() call in the error path.
> 
> Fixes: 524feb799408 ("soc: add aspeed folder and misc drivers")
> Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
> ---
>  drivers/soc/aspeed/aspeed-lpc-snoop.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c
> b/drivers/soc/aspeed/aspeed-lpc-snoop.c
> index 9ab5ba9cf1d6..083ddf6dcb7a 100644
> --- a/drivers/soc/aspeed/aspeed-lpc-snoop.c
> +++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c
> @@ -221,6 +221,7 @@ static int aspeed_lpc_enable_snoop(struct
> aspeed_lpc_snoop *lpc_snoop,
>                 hicrb_en = HICRB_ENSNP1D;
>                 break;
>         default:
> +               misc_deregister(&lpc_snoop->chan[channel].miscdev);

We should free the kfifo too.

Anyway, all the switch statement is doing is setting up mask metadata,
the non-default cases don't depend on the acquired resources. I think
it would make more sense to move it prior to any resource acquisition,
rather than try to unwind their acquisition in the default case.

Andrew


       reply	other threads:[~2024-12-09  0:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20241207032504.1203334-1-joe@pf.is.s.u-tokyo.ac.jp>
2024-12-09  0:28 ` Andrew Jeffery [this message]
2024-12-11  3:52   ` [PATCH] soc: aspeed: deregister a misc device on error Joe Hattori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fff9f13e9839c086d566925c9066d885d46130ed.camel@codeconstruct.com.au \
    --to=andrew@codeconstruct.com.au \
    --cc=joe@pf.is.s.u-tokyo.ac.jp \
    --cc=joel@jms.id.au \
    --cc=linux-aspeed@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox