From: Mike Christie <michael.christie@oracle.com>
To: Peizhi Li <meetlpz@hust.edu.cn>,
Nilesh Javali <njavali@marvell.com>,
Manish Rangankar <mrangankar@marvell.com>,
GR-QLogic-Storage-Upstream@marvell.com,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: hust-os-kernel-patches@googlegroups.com,
Dongliang Mu <dzm91@hust.edu.cn>,
Dan Carpenter <dan.carpenter@linaro.org>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: qedi: qedi_main.c: modify the code flow in 'qedi_alloc_global_queues'
Date: Mon, 24 Apr 2023 10:22:42 -0500 [thread overview]
Message-ID: <a3db8aab-8d30-d470-5eeb-a2cb4195a122@oracle.com> (raw)
In-Reply-To: <20230422101626.1722235-1-meetlpz@hust.edu.cn>
On 4/22/23 5:16 AM, Peizhi Li wrote:
> When goto the mem_alloc_failure, it will result in a null pointer
> reference to variable 'gl' in function 'qedi_free_global_queues',
> due to the 'qedi->global_queues' not being allocated.
>
> Fix this by returning -EINVAL directly.
>
> Signed-off-by: Peizhi Li <meetlpz@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> The issue is found by static analysis and remains untested. Meanwhile,
> this patches is similar with qedf which Jinhong Zhu fixed already.
>
> https://lore.kernel.org/all/20230417135518.184595-1-jinhongzhu@hust.edu.cn/
> drivers/scsi/qedi/qedi_main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
> index f2ee49756df8..34f38e0f1c7d 100644
> --- a/drivers/scsi/qedi/qedi_main.c
> +++ b/drivers/scsi/qedi/qedi_main.c
> @@ -1637,8 +1637,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
> * addresses of our queues
> */
> if (!qedi->p_cpuq) {
> - status = -EINVAL;
> - goto mem_alloc_failure;
> + return -EINVAL;
> }
>
The patch looks ok:
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Looks like there is another issue in this code path though. If
qedi_alloc_global_queues fails in qedi_set_iscsi_pf_param the err_alloc_mem
goto just ends up returning, so the p_cpuq allocation a couple lines before
the qedi_set_iscsi_pf_param call will be leaked.
The __qedi_probe call to qedi_set_iscsi_pf_param just frees the iscsi host,
so it won't be freed via a qedi_free_iscsi_pf_param later. So, I think
qedi_set_iscsi_pf_param's err_alloc_mem goto handler should free the p_cpuq.
next prev parent reply other threads:[~2023-04-24 15:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-22 10:16 Peizhi Li
2023-04-24 4:25 ` [EXT] " Manish Rangankar
2023-04-24 15:22 ` Mike Christie [this message]
[not found] <64474340.013BDF.00009@m126.mail.126.com>
[not found] ` <CADzAj=CYeXvFkhe+6NSObjAcUH4mq+2qXf=kSFd6FGqCAD4_eA@mail.gmail.com>
2023-04-25 9:05 ` Dongliang Mu
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=a3db8aab-8d30-d470-5eeb-a2cb4195a122@oracle.com \
--to=michael.christie@oracle.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=dan.carpenter@linaro.org \
--cc=dzm91@hust.edu.cn \
--cc=hust-os-kernel-patches@googlegroups.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=meetlpz@hust.edu.cn \
--cc=mrangankar@marvell.com \
--cc=njavali@marvell.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®