From: Bart Van Assche <bvanassche@acm.org>
To: Riyan Dhiman <riyandhiman14@gmail.com>,
aacraid@microsemi.com, James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: aacraid: Fix memory leak in open_getadapter_fib function
Date: Tue, 3 Sep 2024 12:18:56 -0700 [thread overview]
Message-ID: <b7f0acf4-5e7d-4491-81be-71518197c58b@acm.org> (raw)
In-Reply-To: <20240903185410.21144-1-riyandhiman14@gmail.com>
On 9/3/24 11:54 AM, Riyan Dhiman wrote:
> In the open_getadapter_fib() function, memory allocated for the fibctx structure
> was not freed when copy_to_user() failed. This can lead to memory leaks as the
> allocated memory remains unreferenced and cannot be reclaimed.
>
> This patch ensures that the allocated memory for fibctx is properly
> freed if copy_to_user() fails, thereby preventing potential memory leaks.
What made you analyze the code modified by this patch?
How has this patch been tested?
> Changes:
> - Added kfree(fibctx); to release memory when copy_to_user() fails.
Changes compared to what? I don't see a version number in the email
subject.
> @@ -220,6 +220,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
> if (copy_to_user(arg, &fibctx->unique,
> sizeof(fibctx->unique))) {
> status = -EFAULT;
> + kfree(fibctx);
> } else {
> status = 0;
> }
Just above the copy_to_user() call there is the following statement:
list_add_tail(&fibctx->next, &dev->fib_list);
Does that mean that the above kfree() will cause list corruption?
Bart.
next prev parent reply other threads:[~2024-09-03 19:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 18:54 Riyan Dhiman
2024-09-03 19:18 ` Bart Van Assche [this message]
2024-09-03 20:30 ` Riyan Dhiman
2024-09-03 21:01 ` Bart Van Assche
2024-09-04 4:43 ` Riyan Dhiman
2024-09-04 4:58 ` Riyan Dhiman
2024-09-04 17:23 ` Bart Van Assche
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=b7f0acf4-5e7d-4491-81be-71518197c58b@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=aacraid@microsemi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=riyandhiman14@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
all inboxes | Powered by JetHome®