public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ma Ke <make24@iscas.ac.cn>
Cc: giometti@enneenne.com, christophe.jaillet@wanadoo.fr,
	linux@treblig.org, sudipm.mukherjee@gmail.com,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] pps: add an error check in parport_attach
Date: Tue, 13 Aug 2024 11:11:23 +0200	[thread overview]
Message-ID: <2024081336-escapable-anemia-87cb@gregkh> (raw)
In-Reply-To: <20240813030800.3949400-1-make24@iscas.ac.cn>

On Tue, Aug 13, 2024 at 11:08:00AM +0800, Ma Ke wrote:
> In parport_attach, the return value of ida_alloc is unchecked, witch leads
> to the use of an invalid index value.
> 
> To address this issue, index should be checked. When the index value is
> abnormal, the device should be freed.
> 
> Found by code review, compile tested only.
> 
> Cc: stable@vger.kernel.org
> Fixes: 55dbc5b5174d ("pps: remove usage of the deprecated ida_simple_xx() API")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  drivers/pps/clients/pps_parport.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c
> index 63d03a0df5cc..9ab7f6961e42 100644
> --- a/drivers/pps/clients/pps_parport.c
> +++ b/drivers/pps/clients/pps_parport.c
> @@ -149,6 +149,11 @@ static void parport_attach(struct parport *port)
>  	}
>  
>  	index = ida_alloc(&pps_client_index, GFP_KERNEL);
> +	if (index < 0) {
> +		pr_err("failed to get index\n");

No need to be noisy, right?

thanks,

greg k-h

  reply	other threads:[~2024-08-13  9:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13  3:08 [PATCH] pps: add an error check in parport_attach Ma Ke
2024-08-13  9:11 ` Greg KH [this message]
2024-08-13  9:51   ` Ma Ke

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=2024081336-escapable-anemia-87cb@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=giometti@enneenne.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@treblig.org \
    --cc=make24@iscas.ac.cn \
    --cc=stable@vger.kernel.org \
    --cc=sudipm.mukherjee@gmail.com \
    /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