Skip to content

Commit e5fcdb7

Browse files
committed
Merge branch 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: n_gsm: gsm_data_alloc buffer allocation could fail and it is not being checked n_gsm: Fix message length handling when building header
2 parents 7bddaac + 093d804 commit e5fcdb7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/tty/n_gsm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
716716
if (msg->len < 128)
717717
*--dp = (msg->len << 1) | EA;
718718
else {
719-
*--dp = ((msg->len & 127) << 1) | EA;
720-
*--dp = (msg->len >> 6) & 0xfe;
719+
*--dp = (msg->len >> 7); /* bits 7 - 15 */
720+
*--dp = (msg->len & 127) << 1; /* bits 0 - 6 */
721721
}
722722
}
723723

@@ -968,6 +968,8 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, u8 *data,
968968
{
969969
struct gsm_msg *msg;
970970
msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype);
971+
if (msg == NULL)
972+
return;
971973
msg->data[0] = (cmd & 0xFE) << 1 | EA; /* Clear C/R */
972974
msg->data[1] = (dlen << 1) | EA;
973975
memcpy(msg->data + 2, data, dlen);

0 commit comments

Comments
 (0)