mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: Ninad Palsule <ninad@linux.ibm.com>,
	jk@ozlabs.org, joel@jms.id.au, alistair@popple.id.au,
	linux-fsi@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] fsi: sbefifo: Handle pending write command
Date: Wed, 11 Oct 2023 14:21:47 -0500	[thread overview]
Message-ID: <8a81172f-e920-88d2-41ec-f9ce90a0afc1@linux.ibm.com> (raw)
In-Reply-To: <20231010204348.2600242-3-ninad@linux.ibm.com>


On 10/10/23 15:43, Ninad Palsule wrote:
> If previous write command is still pending then free it first.
>
> As per the current kernel driver design, write operation prepares a
> buffer for FSI write, the actual FSI write is performed on next read
> operation. There is a possibility of memory leak if buggy application
> sends two back to back writes or two parallel writes.


Reviewed-by: Eddie James <eajames@linux.ibm.com>


>
> Signed-off-by: Ninad Palsule <ninad@linux.ibm.com>
> ---
> v3:
>    - Incorporated review comments by Eddie.
> ---
>   drivers/fsi/fsi-sbefifo.c | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
> index a95b32461f8f3..1cc88a78e588a 100644
> --- a/drivers/fsi/fsi-sbefifo.c
> +++ b/drivers/fsi/fsi-sbefifo.c
> @@ -877,6 +877,13 @@ static ssize_t sbefifo_user_write(struct file *file, const char __user *buf,
>   
>   	mutex_lock(&user->file_lock);
>   
> +	/* If previous write command is still pending then free it. It is safe
> +	 * to do that because read cannot be in progress since we hold the
> +	 * lock.
> +	 */
> +	if (user->pending_cmd)
> +		sbefifo_release_command(user);
> +
>   	/* Can we use the pre-allocate buffer ? If not, allocate */
>   	if (len <= PAGE_SIZE)
>   		user->pending_cmd = user->cmd_page;

      reply	other threads:[~2023-10-11 19:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 20:43 [PATCH v3 0/2] fsi: sbefifo: fixes Ninad Palsule
2023-10-10 20:43 ` [PATCH v3 1/2] fsi: sbefifo: Bump up user write cmd length Ninad Palsule
2023-10-11 13:36   ` Eddie James
2023-10-10 20:43 ` [PATCH v3 2/2] fsi: sbefifo: Handle pending write command Ninad Palsule
2023-10-11 19:21   ` Eddie James [this message]

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=8a81172f-e920-88d2-41ec-f9ce90a0afc1@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=alistair@popple.id.au \
    --cc=jk@ozlabs.org \
    --cc=joel@jms.id.au \
    --cc=linux-fsi@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ninad@linux.ibm.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

Powered by JetHome