mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-05 14:21:37 +00:00
gadget: f_thor: check pointers before use in download_tail()
Some pointers in function download_tail() were not checked before the use. This could possibly cause the data abort. To avoid this, check if the pointers are not null is added. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com> [TestHW: Exynos4412-Trats2]
This commit is contained in:
parent
7da6fa2716
commit
62a96d805f
1 changed files with 14 additions and 2 deletions
|
@ -205,12 +205,24 @@ static long long int download_head(unsigned long long total,
|
||||||
|
|
||||||
static int download_tail(long long int left, int cnt)
|
static int download_tail(long long int left, int cnt)
|
||||||
{
|
{
|
||||||
struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
|
struct dfu_entity *dfu_entity;
|
||||||
void *transfer_buffer = dfu_get_buf(dfu_entity);
|
void *transfer_buffer;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
|
debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
|
||||||
|
|
||||||
|
dfu_entity = dfu_get_entity(alt_setting_num);
|
||||||
|
if (!dfu_entity) {
|
||||||
|
error("Alt setting: %d entity not found!\n", alt_setting_num);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
transfer_buffer = dfu_get_buf(dfu_entity);
|
||||||
|
if (!transfer_buffer) {
|
||||||
|
error("Transfer buffer not allocated!");
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
if (left) {
|
if (left) {
|
||||||
ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
|
ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue