[PATCH] Fix: Correctly handle return value of msgb_pull()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Andreas Eversberg jolly at eversberg.eu
Sat Jan 5 10:13:44 UTC 2013


Now it is possible to use osmoload again to flash. Flashing was
successfully tested with c123 and c155.
---
 src/host/osmocon/osmoload.c                |    2 +-
 src/target/firmware/apps/loader/main.c     |    7 +++++--
 src/target/firmware/apps/loader_mtk/main.c |    4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/host/osmocon/osmoload.c b/src/host/osmocon/osmoload.c
index 9b64935..e83f98a 100644
--- a/src/host/osmocon/osmoload.c
+++ b/src/host/osmocon/osmoload.c
@@ -307,7 +307,7 @@ loader_handle_reply(struct msgb *msg) {
 		length = msgb_pull_u8(msg);
 		crc = msgb_pull_u16(msg);
 		address = msgb_pull_u32(msg);
-		data = msgb_pull(msg, length);
+		data = msgb_pull(msg, length) - length;
 		break;
 	case LOADER_MEM_WRITE:
 		length = msgb_pull_u8(msg);
diff --git a/src/target/firmware/apps/loader/main.c b/src/target/firmware/apps/loader/main.c
index 50a39dd..fd07d0f 100644
--- a/src/target/firmware/apps/loader/main.c
+++ b/src/target/firmware/apps/loader/main.c
@@ -273,7 +273,7 @@ static void cmd_handler(uint8_t dlci, struct msgb *msg)
 		crc = msgb_pull_u16(msg);
 		address = msgb_pull_u32(msg);
 
-		data = msgb_pull(msg, nbytes);
+		data = msgb_pull(msg, nbytes) - nbytes;
 
 		mycrc = osmo_crc16(0, data, nbytes);
 
@@ -391,7 +391,7 @@ static void cmd_handler(uint8_t dlci, struct msgb *msg)
 		chip = msgb_pull_u8(msg);
 		address = msgb_pull_u32(msg);
 
-		data = msgb_pull(msg, nbytes);
+		data = msgb_pull(msg, nbytes) - nbytes;
 
 		mycrc = osmo_crc16(0, data, nbytes);
 
@@ -439,6 +439,9 @@ static void key_handler(enum key_codes code, enum key_states state)
 		puts("Resetting due to keypress.\n");
 		device_reset();
 		break;
+	case KEY_MENU:
+		device_jump((void *)0x10000);
+		break;
 	default:
 		break;
 	}
diff --git a/src/target/firmware/apps/loader_mtk/main.c b/src/target/firmware/apps/loader_mtk/main.c
index 7748dc4..3a12d27 100644
--- a/src/target/firmware/apps/loader_mtk/main.c
+++ b/src/target/firmware/apps/loader_mtk/main.c
@@ -213,7 +213,7 @@ static void cmd_handler(uint8_t dlci, struct msgb *msg)
 		crc = msgb_pull_u16(msg);
 		address = msgb_pull_u32(msg);
 
-		data = msgb_pull(msg, nbytes);
+		data = msgb_pull(msg, nbytes) - nbytes;
 
 		mycrc = osmo_crc16(0, data, nbytes);
 
@@ -331,7 +331,7 @@ static void cmd_handler(uint8_t dlci, struct msgb *msg)
 		chip = msgb_pull_u8(msg);
 		address = msgb_pull_u32(msg);
 
-		data = msgb_pull(msg, nbytes);
+		data = msgb_pull(msg, nbytes) - nbytes;
 
 		mycrc = osmo_crc16(0, data, nbytes);
 
-- 
1.7.3.4


--------------060605070405050509030107
Content-Type: text/plain;
 name="0001-Generate-Compal-E99-binaries-for-loader-and-flash-lo.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-Generate-Compal-E99-binaries-for-loader-and-flash-lo.pa";
 filename*1="tch"



More information about the baseband-devel mailing list