From: Douglas Gilbert <dgilbert@interlog.com>
To: Colin King <colin.king@canonical.com>,
"James E . J . Bottomley" <jejb@linux.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Hannes Reinecke <hare@suse.de>,
linux-scsi@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] scsi: sg: Fix use of pointer sfp after it has been kfree'd
Date: Thu, 11 Mar 2021 12:17:30 -0500 [thread overview]
Message-ID: <a1e80cea-a1b3-9471-8022-2e25eb6c635c@interlog.com> (raw)
In-Reply-To: <20210311103717.7523-1-colin.king@canonical.com>
On 2021-03-11 5:37 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently SG_LOG is referencing sfp after it has been kfree'd which
> is probably a bad thing to do. Fix this by kfree'ing sfp after
> SG_LOG.
>
> Addresses-Coverity: ("Use after free")
> Fixes: af1fc95db445 ("scsi: sg: Replace rq array with xarray")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Thanks.
> ---
> drivers/scsi/sg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 2d4bbc1a1727..79f05afa4407 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -3799,10 +3799,10 @@ sg_add_sfp(struct sg_device *sdp)
> if (rbuf_len > 0) {
> srp = sg_build_reserve(sfp, rbuf_len);
> if (IS_ERR(srp)) {
> - kfree(sfp);
> err = PTR_ERR(srp);
> SG_LOG(1, sfp, "%s: build reserve err=%ld\n", __func__,
> -err);
> + kfree(sfp);
> return ERR_PTR(err);
> }
> if (srp->sgat_h.buflen < rbuf_len) {
>
prev parent reply other threads:[~2021-03-11 17:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 10:37 Colin King
2021-03-11 17:17 ` Douglas Gilbert [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=a1e80cea-a1b3-9471-8022-2e25eb6c635c@interlog.com \
--to=dgilbert@interlog.com \
--cc=colin.king@canonical.com \
--cc=hare@suse.de \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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®