From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
To: Richard Weinberger <rw@linutronix.de>
Cc: linux-mtd@lists.infradead.org, tglx@linutronix.de,
dedekind1@gmail.com, linux-kernel@vger.kernel.org,
tim.bird@am.sony.com
Subject: Re: [RFC][PATCH 6/7] MTD: UBI: Implement checkpointing support
Date: Mon, 20 Feb 2012 18:31:45 +0200 [thread overview]
Message-ID: <20120220183145.6ddbbec0@pixies.home.jungo.com> (raw)
In-Reply-To: <1329250006-22944-7-git-send-email-rw@linutronix.de>
On Tue, 14 Feb 2012 21:06:45 +0100 Richard Weinberger <rw@linutronix.de> wrote:
> Implements UBI checkpointing support.
> It reduces the attaching time from O(N) to O(1).
> Checkpoints are written on demand and upon changes of the volume layout.
> If the recovery from a checkpoint fails we fall back to scanning mode.
Partially reviewed the feature. Great work.
There's some tiny styling/coding issues, will send references if you'd
like.
I'll comment on the feature itself later on.
Meanwhile, there's a potential memleak/crash you might wanna fix.
> +/* Reads the checkpoint data from it's PEBs */
> +struct ubi_scan_info *ubi_read_checkpoint(struct ubi_device *ubi, int cb_sb_pnum)
> +{
> + struct ubi_cp_sb *cpsb;
> + struct ubi_vid_hdr *vh;
> + int ret, i, nblocks;
> + char *cp_raw;
> + size_t cp_size;
> + __be32 data_crc;
> + unsigned long long sqnum = 0;
> + struct ubi_scan_info *si = NULL;
> +
> + cpsb = kmalloc(sizeof(*cpsb), GFP_KERNEL);
> + if (!cpsb) {
> + si = ERR_PTR(-ENOMEM);
> + goto out;
> + }
> +
> + ret = ubi_io_read(ubi, cpsb, cb_sb_pnum, ubi->leb_start, sizeof(*cpsb));
> + if (ret) {
> + ubi_err("Unable to read checkpoint super block");
> + si = ERR_PTR(ret);
> + goto out;
s/goto out/goto free_sb/
(otherwise 'cpsb' not freed)
> + /* cp_raw will contain the whole checkpoint */
> + cp_raw = vzalloc(cp_size);
...
> +
> + cpsb = (struct ubi_cp_sb *)cp_raw;
'cpsb' is overwritten, but formerly kmalloced (at the beginning of
ubi_read_checkpoint).
Should free 'cpsb' prior assignment, or alternatively use different
variable then 'cpsb'.
...
> +
> +free_vhdr:
> + ubi_free_vid_hdr(ubi, vh);
> +free_raw:
> + vfree(cp_raw);
> +free_sb:
> + kfree(cpsb);
Freeing 'cp_raw' and 'cpsb', but in the normal flow, they point to the
same thing.
Regards,
Shmulik
next prev parent reply other threads:[~2012-02-20 16:31 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 20:06 [RFC][PATCH 0/7] UBI " Richard Weinberger
2012-02-14 20:06 ` [RFC][PATCH 1/7] MTD: UBI: Add checkpoint on-chip layout Richard Weinberger
2012-03-07 16:09 ` Artem Bityutskiy
2012-03-07 21:02 ` Richard Weinberger
2012-03-07 22:09 ` Thomas Gleixner
2012-03-07 22:23 ` Thomas Gleixner
2012-02-14 20:06 ` [RFC][PATCH 2/7] MTD: UBI: Add checkpoint struct to ubi_device Richard Weinberger
2012-02-14 20:06 ` [RFC][PATCH 3/7] MTD: UBI: Export next_sqnum() Richard Weinberger
2012-02-14 20:06 ` [RFC][PATCH 4/7] MTD: UBI: Make wl subsystem checkpoint aware Richard Weinberger
2012-02-14 20:06 ` [RFC][PATCH 5/7] MTD: UBI: Make process_eb() " Richard Weinberger
2012-02-14 20:06 ` [RFC][PATCH 6/7] MTD: UBI: Implement checkpointing support Richard Weinberger
2012-02-20 16:31 ` Shmulik Ladkani [this message]
2012-02-14 20:06 ` [RFC][PATCH 7/7] MTD: UBI: wire up checkpointing Richard Weinberger
2012-02-19 13:57 ` Shmulik Ladkani
2012-02-19 14:08 ` Richard Weinberger
2012-02-19 14:40 ` Shmulik Ladkani
2012-02-19 15:08 ` Richard Weinberger
2012-02-29 11:35 ` [RFC][PATCH 0/7] UBI checkpointing support Artem Bityutskiy
2012-02-29 11:36 ` Artem Bityutskiy
2012-02-29 11:40 ` Richard Weinberger
2012-02-29 12:01 ` Artem Bityutskiy
2012-02-29 12:09 ` Artem Bityutskiy
2012-03-07 16:04 ` Artem Bityutskiy
2012-03-07 21:01 ` Richard Weinberger
2012-03-08 11:22 ` Artem Bityutskiy
2012-03-07 16:33 ` Artem Bityutskiy
2012-03-07 21:19 ` Richard Weinberger
2012-03-08 7:08 ` Shmulik Ladkani
2012-03-08 9:21 ` Richard Weinberger
2012-03-08 11:58 ` Artem Bityutskiy
2012-03-08 13:16 ` Shmulik Ladkani
2012-03-08 11:54 ` 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=20120220183145.6ddbbec0@pixies.home.jungo.com \
--to=shmulik.ladkani@gmail.com \
--cc=dedekind1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=rw@linutronix.de \
--cc=tglx@linutronix.de \
--cc=tim.bird@am.sony.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®