From: Sascha Hauer <s.hauer@pengutronix.de>
To: Lucas Stach <l.stach@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: mem: truncate mem device size to fit the loff_t file size
Date: Wed, 7 Nov 2018 08:47:18 +0100 [thread overview]
Message-ID: <20181107074718.s2dsi6phmz4egcov@pengutronix.de> (raw)
In-Reply-To: <20181106161407.20974-1-l.stach@pengutronix.de>
On Tue, Nov 06, 2018 at 05:14:07PM +0100, Lucas Stach wrote:
> On 64bit arches the file covering the whole address space is larger than
> what can be represented in the loff_t type (s64) used for the file size.
> Thus the size of this device is interpreted as negative in a lot of
> places. Fix this by truncating the size to fit the file size type.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> commands/mem.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/commands/mem.c b/commands/mem.c
> index eb91ade05a88..cdd7a492d0d5 100644
> --- a/commands/mem.c
> +++ b/commands/mem.c
> @@ -96,7 +96,8 @@ static int mem_probe(struct device_d *dev)
> dev->priv = cdev;
>
> cdev->name = (char*)dev->resource[0].name;
> - cdev->size = (unsigned long)resource_size(&dev->resource[0]);
> + cdev->size = min(resource_size(&dev->resource[0]),
> + (unsigned long long)S64_MAX);
> cdev->ops = &memops;
> cdev->dev = dev;
>
> --
> 2.19.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-11-07 7:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-06 16:14 Lucas Stach
2018-11-07 7:47 ` Sascha Hauer [this message]
2018-11-07 13:45 ` Peter Mamonov
2018-11-07 16:08 ` Lucas Stach
2018-11-07 17:07 ` Peter Mamonov
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=20181107074718.s2dsi6phmz4egcov@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=l.stach@pengutronix.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