From: Bart Van Assche <bvanassche@acm.org>
To: Abinash Singh <abinashsinghlalotra@gmail.com>, dlemoal@kernel.org
Cc: James.Bottomley@HansenPartnership.com,
linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
martin.petersen@oracle.com
Subject: Re: [PATCH v4] scsi: sd: Fix build warning in sd_revalidate_disk()
Date: Fri, 8 Aug 2025 12:25:56 -0700 [thread overview]
Message-ID: <411260ff-d5c7-4f82-8c47-e66e4828c2b1@acm.org> (raw)
In-Reply-To: <20250808182807.12625-1-abinashsinghlalotra@gmail.com>
On 8/8/25 11:28 AM, Abinash Singh wrote:
> A build warning was triggered due to excessive stack usage in
> sd_revalidate_disk():
> [ ... ]
New versions of a patch should be posted as a new email thread instead
of a reply. Otherwise there is a significant chance that the new version
gets overlooked.
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 4a68b2ab2804..c7fbfb801b40 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3696,10 +3696,10 @@ static int sd_revalidate_disk(struct gendisk *disk)
> struct scsi_disk *sdkp = scsi_disk(disk);
> struct scsi_device *sdp = sdkp->device;
> sector_t old_capacity = sdkp->capacity;
> - struct queue_limits lim;
> - unsigned char *buffer;
> + struct queue_limits *lim = NULL;
> + unsigned char *buffer = NULL;
> unsigned int dev_max;
> - int err;
> + int err = 0;
>
> SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
> "sd_revalidate_disk\n"));
> @@ -3711,6 +3711,13 @@ static int sd_revalidate_disk(struct gendisk *disk)
> if (!scsi_device_online(sdp))
> goto out;
>
> + lim = kmalloc(sizeof(*lim), GFP_KERNEL);
> + if (!lim) {
> + sd_printk(KERN_WARNING, sdkp,
> + "sd_revalidate_disk: Disk limit allocation failure.\n");
> + goto out;
> + }
Returning a negative value for some errors and zero in case of success
or in case of memory allocation failure is confusing.
Since none of the sd_revalidate_disk() callers care about the value
returned by this function, please change the return type of this
function into 'void'. Since that change is logically independent of
allocating 'lim' dynamically, that change probably should be a patch on
its own.
Thanks,
Bart.
prev parent reply other threads:[~2025-08-08 19:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 18:30 [PATCH RFC] " Abinash Singh
2025-08-08 8:01 ` Damien Le Moal
2025-08-08 11:30 ` [PATCH v2] " Abinash Singh
2025-08-08 11:30 ` [PATCH v3] " Abinash Singh
2025-08-08 13:35 ` Damien Le Moal
2025-08-08 13:38 ` [PATCH v2] " Damien Le Moal
2025-08-08 18:28 ` [PATCH v4] " Abinash Singh
2025-08-08 19:25 ` Bart Van Assche [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=411260ff-d5c7-4f82-8c47-e66e4828c2b1@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=abinashsinghlalotra@gmail.com \
--cc=dlemoal@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®