[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e42d5d19-7ed5-468b-98cc-13d0187dc555@kernel.org>
Date: Tue, 3 Jan 2023 09:59:52 +0100
From: Jiri Slaby <jirislaby@...nel.org>
To: Deepak R Varma <drv@...lo.com>,
"Maciej W. Rozycki" <macro@...am.me.uk>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Saurabh Singh Sengar <ssengar@...rosoft.com>,
Praveen Kumar <kumarpraveen@...ux.microsoft.com>
Subject: Re: [PATCH v4 1/2] tty: serial: dz: convert atomic_* to refcount_*
APIs for map_guard
On 26. 12. 22, 7:21, Deepak R Varma wrote:
> The refcount_* APIs are designed to address known issues with the
> atomic_t APIs for reference counting. They provide following distinct
> advantages
> - protect the reference counters from overflow/underflow
> - avoid use-after-free errors
> - provide improved memory ordering guarantee schemes
> - neater and safer.
Really? (see below)
> --- a/drivers/tty/serial/dz.c
> +++ b/drivers/tty/serial/dz.c
...
> @@ -687,23 +686,19 @@ static int dz_map_port(struct uart_port *uport)
> static int dz_request_port(struct uart_port *uport)
> {
> struct dz_mux *mux = to_dport(uport)->mux;
> - int map_guard;
> int ret;
>
> - map_guard = atomic_add_return(1, &mux->map_guard);
> - if (map_guard == 1) {
> - if (!request_mem_region(uport->mapbase, dec_kn_slot_size,
> - "dz")) {
> - atomic_add(-1, &mux->map_guard);
> - printk(KERN_ERR
> - "dz: Unable to reserve MMIO resource\n");
> + refcount_inc(&mux->map_guard);
> + if (refcount_read(&mux->map_guard) == 1) {
This is now racy, right?
thanks,
--
js
suse labs
Powered by blists - more mailing lists