From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Don Brace <don.brace@microsemi.com>,
linux-scsi@vger.kernel.org
Subject: [PATCH 2/4] hpsa: don't bother with vmalloc for BIG_IOCTL_Command_struct
Date: Sat, 30 May 2020 00:40:26 +0100 [thread overview]
Message-ID: <20200529234028.46373-2-viro@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200529234028.46373-1-viro@ZenIV.linux.org.uk>
From: Al Viro <viro@zeniv.linux.org.uk>
"BIG" in the name refers to the amount of data being transferred,
_not_ the size of structure itself; it's 140 or 144 bytes (for
32bit and 64bit hosts resp.). IOCTL_Command_struct is 136 or
144 bytes large...
No point whatsoever turning that into dynamic allocation, let
alone vmalloc one. Just keep it as local variable...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
drivers/scsi/hpsa.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3344a06c938e..64fd97272109 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -6619,21 +6619,17 @@ static int hpsa_ioctl(struct scsi_device *dev, unsigned int cmd,
return rc;
}
case CCISS_BIG_PASSTHRU: {
- BIG_IOCTL_Command_struct *ioc;
+ BIG_IOCTL_Command_struct ioc;
if (!argp)
return -EINVAL;
+ if (copy_from_user(&ioc, argp, sizeof(ioc)))
+ return -EFAULT;
if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0)
return -EAGAIN;
- ioc = vmemdup_user(argp, sizeof(*ioc));
- if (IS_ERR(ioc)) {
- atomic_inc(&h->passthru_cmds_avail);
- return PTR_ERR(ioc);
- }
- rc = hpsa_big_passthru_ioctl(h, ioc);
+ rc = hpsa_big_passthru_ioctl(h, &ioc);
atomic_inc(&h->passthru_cmds_avail);
- if (!rc && copy_to_user(argp, ioc, sizeof(*ioc)))
+ if (!rc && copy_to_user(argp, &ioc, sizeof(ioc)))
rc = -EFAULT;
- kvfree(ioc);
return rc;
}
default:
--
2.11.0
next prev parent reply other threads:[~2020-05-29 23:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200528234025.GT23230@ZenIV.linux.org.uk>
2020-05-29 23:39 ` [PATCHES] uaccess hpsa Al Viro
2020-05-29 23:40 ` [PATCH 1/4] hpsa passthrough: lift {BIG_,}IOCTL_Command_struct copy{in,out} into hpsa_ioctl() Al Viro
2020-05-29 23:40 ` Al Viro [this message]
2020-05-29 23:40 ` [PATCH 3/4] hpsa: get rid of compat_alloc_user_space() Al Viro
2020-05-29 23:40 ` [PATCH 4/4] hpsa_ioctl(): tidy up a bit Al Viro
2020-06-03 1:57 ` [PATCHES] uaccess hpsa Martin K. Petersen
2020-06-03 18:37 ` Don.Brace
2020-06-03 19:17 ` Al Viro
2020-06-03 20:53 ` Martin K. Petersen
2020-06-03 20:54 ` Al Viro
2020-06-04 14:18 ` Martin K. Petersen
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=20200529234028.46373-2-viro@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=don.brace@microsemi.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).