[U-Boot] [PATCH 2/3] mmc: add boundary check for mmc operation
Lei Wen
adrian.wenl at gmail.com
Thu Sep 9 16:31:51 CEST 2010
On Tue, Sep 7, 2010 at 9:49 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Lei Wen,
>
> In message <1283862729-17045-2-git-send-email-leiwen at marvell.com> you wrote:
>> Signed-off-by: Lei Wen <leiwen at marvell.com>
>> ---
>> drivers/mmc/mmc.c | 8 ++++++++
>> 1 files changed, 8 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index 5cc1904..9a50b2f 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -134,6 +134,10 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
>> if (!mmc)
>> return -1;
>>
>> + if (start > mmc->block_dev.lba || (start + blkcnt) > mmc->block_dev.lba) {
>> + printf("\noperation excceed mmc boudary..\n");
>
> No initial newline, please.
You mean add additional line or just reduce a line here?...
>
> Please fix typos: exceed, boundary.
Ok... Sorry for that...
>
> Use puts() instead of printf() for messages that do not need
> formatting.
Em, ok.
>
> Hm... Maybe you could change the message so it is more informatiove,
> i. e. tell the user which boundary was exceeded, and what caused this
> condition - is this a user error or a problem in the code?
Give error message for each judgment of the two?
>
>> err = mmc_set_blocklen(mmc, mmc->write_bl_len);
>> if (err) {
>> printf("set write bl len failed\n\r");
>
> While you are at it: please fix this message, too. Remove the '\r',
> and replace the "bl len" with something the user can understand.
>
>> @@ -236,6 +240,10 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
>> if (!mmc)
>> return 0;
>>
>> + if (start > mmc->block_dev.lba || (start + blkcnt) > mmc->block_dev.lba) {
>> + printf("\noperation excceed mmc boudary..\n");
>
> See above.
>
> Hm... This is repeated code. Factor it out?
It is so hard to factor... There is no common up layer calling, or
down layer calling to add this check...
>
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> There's an old proverb that says just about whatever you want it to.
>
More information about the U-Boot
mailing list