From: Chee, Tien Fong <tien.fong.chee@intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool
Date: Fri, 1 Feb 2019 03:52:09 +0000 [thread overview]
Message-ID: <1548993128.11133.14.camel@intel.com> (raw)
In-Reply-To: <7e521ae6-8741-dff9-79ba-cb7b0237febc@denx.de>
On Thu, 2019-01-31 at 15:23 +0100, Marek Vasut wrote:
> On 1/31/19 1:42 PM, tien.fong.chee at intel.com wrote:
> >
> > From: Tien Fong Chee <tien.fong.chee@intel.com>
> >
> > Release cluster block immediately when no longer use would help to
> > reduce
> > 64KiB memory allocated to the memory pool.
> >
> > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> >
> > ---
> >
> > changes for v2
> > - Assigned NULL to itr after free.
> > - Added NULL checking to itr, avoid freeing twice.
> > ---
> > fs/fat/fat.c | 13 +++++++++++--
> > 1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> > index 347787e..fa846ff 100644
> > --- a/fs/fat/fat.c
> > +++ b/fs/fat/fat.c
> > @@ -1152,12 +1152,21 @@ int file_fat_read_at(const char *filename,
> > loff_t pos, void *buffer,
> > goto out_free_both;
> >
> > debug("reading %s at pos %llu\n", filename, pos);
> > - ret = get_contents(&fsdata, itr->dent, pos, buffer,
> > maxsize, actread);
> > +
> > + /* For saving default max clustersize memory allocated to
> > malloc pool */
> > + dir_entry *dentptr = itr->dent;
> > +
> > + free(itr);
> > +
> > + itr = NULL;
> > +
> > + ret = get_contents(&fsdata, dentptr, pos, buffer, maxsize,
> > actread);
> >
> > out_free_both:
> > free(fsdata.fatbuf);
> > out_free_itr:
> > - free(itr);
> > + if (itr)
> > + free(itr);
> free(NULL) is valid, so you can drop the if conditional.
Noted.
>
> >
> > return ret;
> > }
> >
> >
>
next prev parent reply other threads:[~2019-02-01 3:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 12:42 [U-Boot] [PATCH v2 1/2] fs: fat: dynamically allocate memory for temporary buffer tien.fong.chee at intel.com
2019-01-31 12:42 ` [U-Boot] [PATCH v2 2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool tien.fong.chee at intel.com
2019-01-31 14:23 ` Marek Vasut
2019-02-01 3:52 ` Chee, Tien Fong [this message]
2019-01-31 14:22 ` [U-Boot] [PATCH v2 1/2] fs: fat: dynamically allocate memory for temporary buffer Marek Vasut
2019-02-01 8:11 ` Chee, Tien Fong
2019-02-01 8:19 ` Marek Vasut
2019-02-01 15:20 ` Chee, Tien Fong
2019-02-05 8:30 ` Marek Vasut
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=1548993128.11133.14.camel@intel.com \
--to=tien.fong.chee@intel.com \
--cc=u-boot@lists.denx.de \
/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