From: Artem Bityutskiy <dedekind1@gmail.com>
To: Rohit Hassan Sathyanarayan <rohit.hs@samsung.com>
Cc: 'David Woodhouse' <dwmw2@infradead.org>,
v.dalal@samsung.com, linux-mtd@lists.infradead.org
Subject: RE: [PATCH 1/1][MTD] Adding IOCTLs for run-time partitioning support
Date: Sat, 18 Sep 2010 21:57:21 +0300 [thread overview]
Message-ID: <1284836241.1721.109.camel@brekeke> (raw)
In-Reply-To: <002c01cb4d6c$0e2bf680$2a83e380$%hs@samsung.com>
On Mon, 2010-09-06 at 08:04 +0530, Rohit Hassan Sathyanarayan wrote:
> + case MTDPARTITIONCREATE:
> + {
> + u_int64_t uoffset = 0;
> + u_int64_t usize = 0;
> + u_int32_t i;
> +
> + if (copy_from_user(&upart, argp,
> + sizeof(struct user_mtd_info))) {
> + ret = -EFAULT;
> + break;
> + }
> + ppart = kzalloc(sizeof(struct user_mtd)*
> + upart.num_partitions
> + , GFP_KERNEL);
> + pmtd = kzalloc(sizeof(struct mtd_partition)*
> + upart.num_partitions,
> + GFP_KERNEL);
> + pmtd1 = pmtd;
> + if (ppart == NULL) {
> + ret = -EFAULT;
> + break;
> + }
> + if (copy_from_user(ppart,
> + upart.pst_user_partitions,
> + sizeof(struct user_mtd)*
> + upart.num_partitions)) {
> + ret = -EFAULT;
> + break;
> + }
> + for (i = 0; i < upart.num_partitions; i++) {
> + pmtd->name = ppart->name;
> + pmtd->size =
> + ppart->partition_size;
> + usize += pmtd->size;
> + pmtd->offset =
> + ppart->partition_offset;
> + uoffset += pmtd->offset;
> + pmtd->mask_flags =
> + ppart->partition_mask;
> +
> + ppart++;
> + pmtd++;
> + }
> + add_mtd_partitions(mtd, pmtd1,
> + upart.num_partitions);
> + if ((mtd->size - usize) > 0) {
> + free.name = "FREE";
> + free.size = mtd->size - usize;
> + free.offset = usize;
> + free.mask_flags = 0;
> + add_mtd_partitions(mtd, &free, 1);
> + }
> + kfree(pmtd1);
> + break;
> + }
So what happens if you already have many partitions, and this ioctl is
called? Where these existing partitions and the existing master device
will go? Who will free the resources occupied by them and where?
> +struct user_mtd_info {
> + struct user_mtd *pst_user_partitions;
> + __u32 num_partitions;
> +};
I suggested you to look at the discussion of Roman's patches - we did
discuss there that pointers in ioctls are bad, because then you have to
have implement compat_ioctl. You need to use u64 to avoid problems in
64-bit kernel + 32-bit user-space environments.
--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)
next prev parent reply other threads:[~2010-09-18 18:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-29 11:30 [PATCH 1/1][MTD] Adding IOCTLs for run-time partitioning support Rohit Hassan Sathyanarayan
2010-08-23 14:33 ` Artem Bityutskiy
2010-09-06 2:34 ` Rohit Hassan Sathyanarayan
2010-09-18 18:57 ` Artem Bityutskiy [this message]
2010-09-02 13:24 ` Roman Tereshonkov
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=1284836241.1721.109.camel@brekeke \
--to=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=rohit.hs@samsung.com \
--cc=v.dalal@samsung.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;
as well as URLs for NNTP newsgroup(s).