From: Michael Chang <mchang@suse.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH v3 1/2] lvm: add lvm cache logical volume handling
Date: Wed, 18 Mar 2020 16:42:17 +0800 [thread overview]
Message-ID: <20200318084217.GA32131@mercury> (raw)
In-Reply-To: <20200313122342.y3tkkavbd4sp7ujp@tomti.i.net-space.pl>
On Fri, Mar 13, 2020 at 01:23:42PM +0100, Daniel Kiper wrote:
> On Wed, Mar 04, 2020 at 02:44:52PM +0800, Michael Chang wrote:
[snip]
> > @@ -243,6 +279,8 @@ grub_lvm_detect (grub_disk_t disk,
> >
> > if (! vg)
> > {
> > + struct cache_lv *cache_lvs = NULL;
> > +
> > /* First time we see this volume group. We've to create the
> > whole volume group structure. */
> > vg = grub_malloc (sizeof (*vg));
> > @@ -672,6 +710,101 @@ grub_lvm_detect (grub_disk_t disk,
> > seg->nodes[seg->node_count - 1].name = tmp;
> > }
> > }
> > + else if (grub_memcmp (p, "cache\"",
> > + sizeof ("cache\"") - 1) == 0)
> > + {
> > + struct cache_lv *cache = NULL;
> > +
> > + char *p2, *p3;
> > + grub_ssize_t sz;
>
> Why not grub_size_t?
That declaration was used in similar parts throughout the file and I
think I was just doing copy-and-paste without thinking too much.
Certainly grub_size_t looks better for me too. I will fix that and send
next version.
>
> > +
> > + cache = grub_zalloc (sizeof (*cache));
> > + if (!cache)
> > + goto cache_lv_fail;
> > + cache->lv = grub_zalloc (sizeof (*cache->lv));
> > + if (!cache->lv)
> > + goto cache_lv_fail;
> > + grub_memcpy (cache->lv, lv, sizeof (*cache->lv));
> > +
[snip]
> > +
> > + cache_lv_fail:
> > + if (cache)
> > + {
> > + grub_free (cache->origin);
> > + grub_free (cache->cache_pool);
> > + grub_free (cache->lv->fullname);
>
> If "cache = grub_zalloc (sizeof (*cache));" fails above then
> here GRUB crashes due to NULL pointer dereference...
>
> > + grub_free (cache->lv->idname);
>
> ...this has to be fixed too...
>
> > + grub_free (cache->lv->name);
>
> Ditto...
Arh, same mistake again! I'll fix them in next version.
Thanks a lot for review.
Michael
>
> > + grub_free (cache);
> > + }
> > + goto fail4;
> > + }
> > else
> > {
> > #ifdef GRUB_UTIL
>
> Daniel
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
prev parent reply other threads:[~2020-03-18 8:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-04 6:44 [PATCH v3 1/2] lvm: add lvm cache logical volume handling Michael Chang
2020-03-04 6:44 ` [PATCH v3 2/2] docs: Document notes on LVM cache booting Michael Chang
2020-03-13 12:26 ` Daniel Kiper
2020-03-13 12:23 ` [PATCH v3 1/2] lvm: add lvm cache logical volume handling Daniel Kiper
2020-03-18 8:42 ` Michael Chang [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=20200318084217.GA32131@mercury \
--to=mchang@suse.com \
--cc=grub-devel@gnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.