public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Ma Ke <make24@iscas.ac.cn>
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] media: lirc: Fix error handling in lirc_register()
Date: Mon, 6 Jan 2025 10:56:13 +0000	[thread overview]
Message-ID: <Z3u2zVQyammNo_o3@gofer.mess.org> (raw)
In-Reply-To: <20250105100101.275309-1-make24@iscas.ac.cn>

Hi,

On Sun, Jan 05, 2025 at 06:01:01PM +0800, Ma Ke wrote:
> When cdev_device_add() failed, calling put_device() to explicitly
> release dev->lirc_dev. Otherwise, it could cause the fault of the
> reference count.
> 
> Found by code review.

Interesting find, thanks for finding and reporting.

So I think the idea is right, but there is a problem. lirc_release_device()
will do a put_device() on the rcdev, but no corresponding get_device() is
done in this code path.


Sean

> 
> Cc: stable@vger.kernel.org
> Fixes: a6ddd4fecbb0 ("media: lirc: remove last remnants of lirc kapi")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  drivers/media/rc/lirc_dev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
> index a2257dc2f25d..ed839e15fa16 100644
> --- a/drivers/media/rc/lirc_dev.c
> +++ b/drivers/media/rc/lirc_dev.c
> @@ -765,6 +765,7 @@ int lirc_register(struct rc_dev *dev)
>  	return 0;
>  
>  out_ida:
> +	put_device(&dev->lirc_dev);
>  	ida_free(&lirc_ida, minor);
>  	return err;
>  }
> -- 
> 2.25.1

  reply	other threads:[~2025-01-06 11:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-05 10:01 [PATCH] media: lirc: Fix error handling in lirc_register() Ma Ke
2025-01-06 10:56 ` Sean Young [this message]
2025-01-07  1:51   ` Ma Ke
2025-01-07 10:38     ` Sean Young

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=Z3u2zVQyammNo_o3@gofer.mess.org \
    --to=sean@mess.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=make24@iscas.ac.cn \
    --cc=mchehab@kernel.org \
    --cc=stable@vger.kernel.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