From: Artem Bityutskiy <dedekind1@gmail.com>
To: Christian Riesch <christian.riesch@omicron.at>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: mtdchar: Exit write loop when hitting end of OTP memory
Date: Wed, 29 May 2013 10:08:18 +0300 [thread overview]
Message-ID: <1369811298.5446.215.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <29483dd6-387c-4b28-b689-88795e0bbbde@mary.at.omicron.at>
On Fri, 2013-04-26 at 19:56 +0200, Christian Riesch wrote:
> If a write to one time programmable memory (OTP) hits the end
> of this memory area, no more data can be written and count does not
> decrease anymore. We are trapped in the loop forever.
>
> Therefore drop the remaining data if retlen != len.
>
> Signed-off-by: Christian Riesch <christian.riesch@omicron.at>
> ---
> drivers/mtd/mtdchar.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index e0e59bf..70c18c2 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -321,6 +321,10 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
> case MTD_FILE_MODE_OTP_USER:
> ret = mtd_write_user_prot_reg(mtd, *ppos, len,
> &retlen, kbuf);
> +
> + /* if we hit the end of otp memory, drop the rest */
> + if (retlen != len)
> + count -= len - retlen;
> break;
I think the problem is that 'mtd_write_user_prot_reg()' should return an
error if you try to write more data than it is available. At least this
is the behavior of 'mtd_write()'.
--
Best Regards,
Artem Bityutskiy
next prev parent reply other threads:[~2013-05-29 7:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 17:56 [PATCH] mtd: mtdchar: Exit write loop when hitting end of OTP memory Christian Riesch
2013-05-29 7:08 ` Artem Bityutskiy [this message]
2013-05-29 13:19 ` Christian Riesch
2013-05-29 13:56 ` Artem Bityutskiy
2013-05-29 14:27 ` Christian Riesch
2013-06-03 9:39 ` Artem Bityutskiy
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=1369811298.5446.215.camel@sauron.fi.intel.com \
--to=dedekind1@gmail.com \
--cc=christian.riesch@omicron.at \
--cc=linux-mtd@lists.infradead.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