Loading drivers/char/diag/diagchar.h +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #define DIAG_MAX_REQ_SIZE (16 * 1024) #define DIAG_MAX_RSP_SIZE (16 * 1024) #define APF_DIAG_PADDING 256 /* * In the worst case, the HDLC buffer can be atmost twice the size of the * original packet. Add 3 bytes for 16 bit CRC (2 bytes) and a delimiter Loading drivers/char/diag/diagchar_core.c +11 −6 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ void diag_add_client(int i, struct file *file) static void diag_mempool_init(void) { uint32_t itemsize = DIAG_MAX_REQ_SIZE; uint32_t itemsize_hdlc = DIAG_MAX_HDLC_BUF_SIZE; uint32_t itemsize_hdlc = DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING; uint32_t itemsize_dci = IN_BUF_SIZE; uint32_t itemsize_user = DCI_REQ_BUF_SIZE; Loading Loading @@ -1849,7 +1849,8 @@ static int diag_process_apps_data_hdlc(unsigned char *buf, int len, send.terminate = 1; if (!data->buf) data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading @@ -1865,7 +1866,8 @@ static int diag_process_apps_data_hdlc(unsigned char *buf, int len, } data->buf = NULL; data->len = 0; data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading Loading @@ -1893,7 +1895,8 @@ static int diag_process_apps_data_hdlc(unsigned char *buf, int len, } data->buf = NULL; data->len = 0; data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading Loading @@ -1954,7 +1957,8 @@ static int diag_process_apps_data_non_hdlc(unsigned char *buf, int len, } if (!data->buf) { data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading @@ -1971,7 +1975,8 @@ static int diag_process_apps_data_non_hdlc(unsigned char *buf, int len, } data->buf = NULL; data->len = 0; data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading drivers/char/diag/diagfwd.c +2 −1 Original line number Diff line number Diff line Loading @@ -1464,7 +1464,8 @@ int diagfwd_init(void) mutex_init(&driver->diag_hdlc_mutex); mutex_init(&driver->diag_cntl_mutex); mutex_init(&driver->mode_lock); driver->encoded_rsp_buf = kzalloc(DIAG_MAX_HDLC_BUF_SIZE, GFP_KERNEL); driver->encoded_rsp_buf = kzalloc(DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, GFP_KERNEL); if (!driver->encoded_rsp_buf) goto err; kmemleak_not_leak(driver->encoded_rsp_buf); Loading drivers/char/diag/diagfwd_peripheral.c +15 −6 Original line number Diff line number Diff line Loading @@ -199,7 +199,8 @@ static int check_bufsize_for_encoding(struct diagfwd_buf_t *buf, uint32_t len) } if (buf->len < max_size) { temp_buf = krealloc(buf->data, max_size, temp_buf = krealloc(buf->data, max_size + APF_DIAG_PADDING, GFP_KERNEL); if (!temp_buf) return -ENOMEM; Loading Loading @@ -992,7 +993,9 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) kmemleak_not_leak(fwd_info->buf_1); } if (!fwd_info->buf_1->data) { fwd_info->buf_1->data = kzalloc(PERIPHERAL_BUF_SZ, GFP_ATOMIC); fwd_info->buf_1->data = kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_1->data) goto err; fwd_info->buf_1->len = PERIPHERAL_BUF_SZ; Loading @@ -1011,7 +1014,8 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) } if (!fwd_info->buf_2->data) { fwd_info->buf_2->data = kzalloc(PERIPHERAL_BUF_SZ, fwd_info->buf_2->data = kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_2->data) goto err; Loading @@ -1026,7 +1030,9 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) /* In support of hdlc encoding */ if (!fwd_info->buf_1->data_raw) { fwd_info->buf_1->data_raw = kzalloc(PERIPHERAL_BUF_SZ, GFP_ATOMIC); kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_1->data_raw) goto err; fwd_info->buf_1->len_raw = PERIPHERAL_BUF_SZ; Loading @@ -1034,7 +1040,9 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) } if (!fwd_info->buf_2->data_raw) { fwd_info->buf_2->data_raw = kzalloc(PERIPHERAL_BUF_SZ, GFP_ATOMIC); kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_2->data_raw) goto err; fwd_info->buf_2->len_raw = PERIPHERAL_BUF_SZ; Loading @@ -1046,7 +1054,8 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) if (fwd_info->type == TYPE_CMD && driver->supports_apps_hdlc_encoding) { /* In support of hdlc encoding */ if (!fwd_info->buf_1->data_raw) { fwd_info->buf_1->data_raw = kzalloc(PERIPHERAL_BUF_SZ, fwd_info->buf_1->data_raw = kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_1->data_raw) goto err; Loading Loading
drivers/char/diag/diagchar.h +1 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #define DIAG_MAX_REQ_SIZE (16 * 1024) #define DIAG_MAX_RSP_SIZE (16 * 1024) #define APF_DIAG_PADDING 256 /* * In the worst case, the HDLC buffer can be atmost twice the size of the * original packet. Add 3 bytes for 16 bit CRC (2 bytes) and a delimiter Loading
drivers/char/diag/diagchar_core.c +11 −6 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ void diag_add_client(int i, struct file *file) static void diag_mempool_init(void) { uint32_t itemsize = DIAG_MAX_REQ_SIZE; uint32_t itemsize_hdlc = DIAG_MAX_HDLC_BUF_SIZE; uint32_t itemsize_hdlc = DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING; uint32_t itemsize_dci = IN_BUF_SIZE; uint32_t itemsize_user = DCI_REQ_BUF_SIZE; Loading Loading @@ -1849,7 +1849,8 @@ static int diag_process_apps_data_hdlc(unsigned char *buf, int len, send.terminate = 1; if (!data->buf) data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading @@ -1865,7 +1866,8 @@ static int diag_process_apps_data_hdlc(unsigned char *buf, int len, } data->buf = NULL; data->len = 0; data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading Loading @@ -1893,7 +1895,8 @@ static int diag_process_apps_data_hdlc(unsigned char *buf, int len, } data->buf = NULL; data->len = 0; data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading Loading @@ -1954,7 +1957,8 @@ static int diag_process_apps_data_non_hdlc(unsigned char *buf, int len, } if (!data->buf) { data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading @@ -1971,7 +1975,8 @@ static int diag_process_apps_data_non_hdlc(unsigned char *buf, int len, } data->buf = NULL; data->len = 0; data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE, data->buf = diagmem_alloc(driver, DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, POOL_TYPE_HDLC); if (!data->buf) { ret = PKT_DROP; Loading
drivers/char/diag/diagfwd.c +2 −1 Original line number Diff line number Diff line Loading @@ -1464,7 +1464,8 @@ int diagfwd_init(void) mutex_init(&driver->diag_hdlc_mutex); mutex_init(&driver->diag_cntl_mutex); mutex_init(&driver->mode_lock); driver->encoded_rsp_buf = kzalloc(DIAG_MAX_HDLC_BUF_SIZE, GFP_KERNEL); driver->encoded_rsp_buf = kzalloc(DIAG_MAX_HDLC_BUF_SIZE + APF_DIAG_PADDING, GFP_KERNEL); if (!driver->encoded_rsp_buf) goto err; kmemleak_not_leak(driver->encoded_rsp_buf); Loading
drivers/char/diag/diagfwd_peripheral.c +15 −6 Original line number Diff line number Diff line Loading @@ -199,7 +199,8 @@ static int check_bufsize_for_encoding(struct diagfwd_buf_t *buf, uint32_t len) } if (buf->len < max_size) { temp_buf = krealloc(buf->data, max_size, temp_buf = krealloc(buf->data, max_size + APF_DIAG_PADDING, GFP_KERNEL); if (!temp_buf) return -ENOMEM; Loading Loading @@ -992,7 +993,9 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) kmemleak_not_leak(fwd_info->buf_1); } if (!fwd_info->buf_1->data) { fwd_info->buf_1->data = kzalloc(PERIPHERAL_BUF_SZ, GFP_ATOMIC); fwd_info->buf_1->data = kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_1->data) goto err; fwd_info->buf_1->len = PERIPHERAL_BUF_SZ; Loading @@ -1011,7 +1014,8 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) } if (!fwd_info->buf_2->data) { fwd_info->buf_2->data = kzalloc(PERIPHERAL_BUF_SZ, fwd_info->buf_2->data = kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_2->data) goto err; Loading @@ -1026,7 +1030,9 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) /* In support of hdlc encoding */ if (!fwd_info->buf_1->data_raw) { fwd_info->buf_1->data_raw = kzalloc(PERIPHERAL_BUF_SZ, GFP_ATOMIC); kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_1->data_raw) goto err; fwd_info->buf_1->len_raw = PERIPHERAL_BUF_SZ; Loading @@ -1034,7 +1040,9 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) } if (!fwd_info->buf_2->data_raw) { fwd_info->buf_2->data_raw = kzalloc(PERIPHERAL_BUF_SZ, GFP_ATOMIC); kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_2->data_raw) goto err; fwd_info->buf_2->len_raw = PERIPHERAL_BUF_SZ; Loading @@ -1046,7 +1054,8 @@ void diagfwd_buffers_init(struct diagfwd_info *fwd_info) if (fwd_info->type == TYPE_CMD && driver->supports_apps_hdlc_encoding) { /* In support of hdlc encoding */ if (!fwd_info->buf_1->data_raw) { fwd_info->buf_1->data_raw = kzalloc(PERIPHERAL_BUF_SZ, fwd_info->buf_1->data_raw = kzalloc(PERIPHERAL_BUF_SZ + APF_DIAG_PADDING, GFP_ATOMIC); if (!fwd_info->buf_1->data_raw) goto err; Loading