From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"target-devel@vger.kernel.org" <target-devel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Abaci Robot <abaci@linux.alibaba.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Subject: Re: [PATCH] scsi: target: return -ENOMEM when kzalloc failed
Date: Thu, 30 Mar 2023 07:59:03 +0000 [thread overview]
Message-ID: <73695d8e-a779-3c9c-5a46-b5a23381dff2@nvidia.com> (raw)
In-Reply-To: <20230330023834.97455-1-jiapeng.chong@linux.alibaba.com>
On 3/29/23 19:38, Jiapeng Chong wrote:
> The driver is using -1 instead of the -ENOMEM defined macro to specify
> that a buffer allocation failed.
>
> drivers/target/iscsi/iscsi_target.c:691 iscsi_target_init_module() warn: returning -1 instead of -ENOMEM is sloppy.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4644
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> drivers/target/iscsi/iscsi_target.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 834cce50f9b0..d3a40c3caaf5 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -688,7 +688,7 @@ static int __init iscsi_target_init_module(void)
> pr_debug("iSCSI-Target "ISCSIT_VERSION"\n");
> iscsit_global = kzalloc(sizeof(*iscsit_global), GFP_KERNEL);
> if (!iscsit_global)
> - return -1;
> + return -ENOMEM;
>
> spin_lock_init(&iscsit_global->ts_bitmap_lock);
> mutex_init(&auth_id_lock);
you can also just use goto out, it has return -ENOMEM, no biggy..
Also, it will be useful to print the error message here as we
are making this change..
irrespective of that :
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
next prev parent reply other threads:[~2023-03-30 7:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 2:38 Jiapeng Chong
2023-03-30 7:59 ` Chaitanya Kulkarni [this message]
2023-03-30 11:00 ` Damien Le Moal
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=73695d8e-a779-3c9c-5a46-b5a23381dff2@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=abaci@linux.alibaba.com \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.kernel.org \
/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®