I must admit that I don't know much about PTP. But here are my ideas, what could go wrong.
- - Could it be that PTP splits up the file into chunks and you just simply forget the last one? I just skimmed the code and I don't know how the loop you are talking about exactly looks like, but could it be, that you should 'extend' it by one iteration?
- - Also - I don't know if you already mentioned that - have you checked if the error occurs when writing the file? Compare the size of the data you receive with the one you write into a file.
- - Are you 100% sure, that you send all the data?
- - Maybe you stop the transfer too early?
- - Maybe you have an error in the calculation of the size? Looks like, whatever file you send, you miss the last 9% (or factor 1.1333).
Check if the calculation is right.
Again, I just barely know that PTP is a protocol, but have no clue on how that stuff internally works.
Edit: I just noticed:
-(solved)current ML codes not handle USB ack packet(Simply discarding now.)
*it's 12byte data adding each after part of USB_BULK_WRITE data.
-USB_BULK_WRITE is sending 500byte data
- Maybe these 12bytes mess up your calculation of the size? I know, 12bytes on 500bytes just makes approx 2%, not 9%. Maybe not as useful as you properly hoped - I do what I can

Another Edit: (I just noticed, that the crap I previously wrote was absolutely useless)
I just found enough motivation to take a closer look at the code. It looks totally okay to me. I assume that fninfo_len is the length of some sort of header which is being skipped, right?
- I would write the received data into a buffer instead of writing it directly into the file. Doing all the writing once is faster.
- Have you tried to simply save everything you receive? Then you could send a small file, 2k or something and take a closer look at, what it ends up with.
- And finally: is context->get_data_size() with or without headers, signatures and that kind of stuff.
Btw: how are you sending files?