OSDN Git Service

diag: Fix possible kernel addresses leak
authorManoj Prabhu B <bmanoj@codeaurora.org>
Tue, 12 Apr 2016 05:57:39 +0000 (11:27 +0530)
committerJeevan Shriram <jshriram@codeaurora.org>
Thu, 19 May 2016 23:10:45 +0000 (16:10 -0700)
This patch addresses kernel addresses leak by changing
the format specifier to adhere to the kptr_restrict system setting.

CRs-Fixed: 987013
Change-Id: I32649a26f54d96c56d80aa2a1bd5f5d9dd0dd9d3
Signed-off-by: Manoj Prabhu B <bmanoj@codeaurora.org>
13 files changed:
drivers/char/diag/diag_dci.c
drivers/char/diag/diag_debugfs.c
drivers/char/diag/diag_masks.c
drivers/char/diag/diag_memorydevice.c
drivers/char/diag/diag_usb.c
drivers/char/diag/diagchar_core.c
drivers/char/diag/diagfwd.c
drivers/char/diag/diagfwd_bridge.c
drivers/char/diag/diagfwd_hsic.c
drivers/char/diag/diagfwd_mhi.c
drivers/char/diag/diagfwd_peripheral.c
drivers/char/diag/diagfwd_smd.c
drivers/char/diag/diagfwd_socket.c

index c077a55..2a9ad0d 100644 (file)
@@ -411,7 +411,7 @@ static int diag_process_single_dci_pkt(unsigned char *buf, int len,
        uint8_t cmd_code = 0;
 
        if (!buf || len < 0) {
-               pr_err("diag: Invalid input in %s, buf: %p, len: %d\n",
+               pr_err("diag: Invalid input in %s, buf: %pK, len: %d\n",
                        __func__, buf, len);
                return -EIO;
        }
@@ -762,7 +762,7 @@ static int diag_dci_remove_req_entry(unsigned char *buf, int len,
 {
        uint16_t rsp_count = 0, delayed_rsp_id = 0;
        if (!buf || len <= 0 || !entry) {
-               pr_err("diag: In %s, invalid input buf: %p, len: %d, entry: %p\n",
+               pr_err("diag: In %s, invalid input buf: %pK, len: %d, entry: %pK\n",
                        __func__, buf, len, entry);
                return -EIO;
        }
@@ -816,7 +816,7 @@ static void dci_process_ctrl_status(unsigned char *buf, int len, int token)
        int peripheral_mask, status;
 
        if (!buf || (len < sizeof(struct diag_ctrl_dci_status))) {
-               pr_err("diag: In %s, invalid buf %p or length: %d\n",
+               pr_err("diag: In %s, invalid buf %pK or length: %d\n",
                       __func__, buf, len);
                return;
        }
@@ -2006,7 +2006,7 @@ int diag_process_dci_transaction(unsigned char *buf, int len)
                        mutex_unlock(&driver->dci_mutex);
                        return -ENOMEM;
                }
-               pr_debug("diag: head of dci log mask %p\n", head_log_mask_ptr);
+               pr_debug("diag: head of dci log mask %pK\n", head_log_mask_ptr);
                count = 0; /* iterator for extracting log codes */
 
                while (count < num_codes) {
@@ -2036,7 +2036,7 @@ int diag_process_dci_transaction(unsigned char *buf, int len)
                        while (log_mask_ptr && (offset < DCI_LOG_MASK_SIZE)) {
                                if (*log_mask_ptr == equip_id) {
                                        found = 1;
-                                       pr_debug("diag: find equip id = %x at %p\n",
+                                       pr_debug("diag: find equip id = %x at %pK\n",
                                                 equip_id, log_mask_ptr);
                                        break;
                                } else {
@@ -2120,7 +2120,7 @@ int diag_process_dci_transaction(unsigned char *buf, int len)
                        mutex_unlock(&driver->dci_mutex);
                        return -ENOMEM;
                }
-               pr_debug("diag: head of dci event mask %p\n", event_mask_ptr);
+               pr_debug("diag: head of dci event mask %pK\n", event_mask_ptr);
                count = 0; /* iterator for extracting log codes */
                while (count < num_codes) {
                        if (read_len >= USER_SPACE_DATA) {
@@ -3013,7 +3013,7 @@ int diag_dci_write_proc(uint8_t peripheral, int pkt_type, char *buf, int len)
        if (!buf || peripheral >= NUM_PERIPHERALS || len < 0 ||
            !(driver->feature[PERIPHERAL_MODEM].rcvd_feature_mask)) {
                DIAG_LOG(DIAG_DEBUG_DCI,
-                       "buf: 0x%p, p: %d, len: %d, f_mask: %d\n",
+                       "buf: 0x%pK, p: %d, len: %d, f_mask: %d\n",
                                buf, peripheral, len,
                                driver->feature[peripheral].rcvd_feature_mask);
                return -EINVAL;
index bb73ee0..f5e4eba 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -428,7 +428,7 @@ static ssize_t diag_dbgfs_read_usbinfo(struct file *file, char __user *ubuf,
                bytes_written = scnprintf(buf+bytes_in_buffer, bytes_remaining,
                        "id: %d\n"
                        "name: %s\n"
-                       "hdl: %p\n"
+                       "hdl: %pK\n"
                        "connected: %d\n"
                        "diag state: %d\n"
                        "enabled: %d\n"
@@ -527,7 +527,7 @@ static ssize_t diag_dbgfs_read_smdinfo(struct file *file, char __user *ubuf,
                        bytes_written = scnprintf(buf+bytes_in_buffer,
                                bytes_remaining,
                                "name\t\t:\t%s\n"
-                               "hdl\t\t:\t%p\n"
+                               "hdl\t\t:\t%pK\n"
                                "inited\t\t:\t%d\n"
                                "opened\t\t:\t%d\n"
                                "diag_state\t:\t%d\n"
@@ -633,7 +633,7 @@ static ssize_t diag_dbgfs_read_socketinfo(struct file *file, char __user *ubuf,
                        bytes_written = scnprintf(buf+bytes_in_buffer,
                                bytes_remaining,
                                "name\t\t:\t%s\n"
-                               "hdl\t\t:\t%p\n"
+                               "hdl\t\t:\t%pK\n"
                                "inited\t\t:\t%d\n"
                                "opened\t\t:\t%d\n"
                                "diag_state\t:\t%d\n"
@@ -823,9 +823,9 @@ static ssize_t diag_dbgfs_read_mhiinfo(struct file *file, char __user *ubuf,
                        "bridge index: %s\n"
                        "mempool: %s\n"
                        "read ch opened: %d\n"
-                       "read ch hdl: %p\n"
+                       "read ch hdl: %pK\n"
                        "write ch opened: %d\n"
-                       "write ch hdl: %p\n"
+                       "write ch hdl: %pK\n"
                        "read work pending: %d\n"
                        "read done work pending: %d\n"
                        "open work pending: %d\n"
@@ -900,9 +900,9 @@ static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf,
                        "type: %d\n"
                        "inited: %d\n"
                        "ctxt: %d\n"
-                       "dev_ops: %p\n"
-                       "dci_read_buf: %p\n"
-                       "dci_read_ptr: %p\n"
+                       "dev_ops: %pK\n"
+                       "dci_read_buf: %pK\n"
+                       "dci_read_ptr: %pK\n"
                        "dci_read_len: %d\n\n",
                        info->id,
                        info->name,
index 42c8d57..7a33143 100644 (file)
@@ -397,7 +397,7 @@ static void diag_send_time_sync_update(uint8_t peripheral)
 
        if (!driver->diagfwd_cntl[peripheral] ||
                !driver->diagfwd_cntl[peripheral]->ch_open) {
-               pr_err("diag: In %s, control channel is not open, p: %d, %p\n",
+               pr_err("diag: In %s, control channel is not open, p: %d, %pK\n",
                        __func__, peripheral, driver->diagfwd_cntl[peripheral]);
                return;
        }
@@ -433,7 +433,7 @@ static void diag_send_feature_mask_update(uint8_t peripheral)
 
        if (!driver->diagfwd_cntl[peripheral] ||
            !driver->diagfwd_cntl[peripheral]->ch_open) {
-               pr_err("diag: In %s, control channel is not open, p: %d, %p\n",
+               pr_err("diag: In %s, control channel is not open, p: %d, %pK\n",
                       __func__, peripheral, driver->diagfwd_cntl[peripheral]);
                return;
        }
@@ -485,7 +485,7 @@ static int diag_cmd_get_ssid_range(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &msg_mask : info->msg_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -531,7 +531,7 @@ static int diag_cmd_get_build_mask(unsigned char *src_buf, int src_len,
        struct diag_msg_build_mask_t rsp;
 
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d\n",
                       __func__, src_buf, src_len, dest_buf, dest_len);
                return -EINVAL;
        }
@@ -588,7 +588,7 @@ static int diag_cmd_get_msg_mask(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &msg_mask : info->msg_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -646,7 +646,7 @@ static int diag_cmd_set_msg_mask(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &msg_mask : info->msg_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -759,7 +759,7 @@ static int diag_cmd_set_all_msg_mask(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &msg_mask : info->msg_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -812,7 +812,7 @@ static int diag_cmd_get_event_mask(unsigned char *src_buf, int src_len,
        struct diag_event_mask_config_t rsp;
 
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d\n",
                       __func__, src_buf, src_len, dest_buf, dest_len);
                return -EINVAL;
        }
@@ -854,7 +854,7 @@ static int diag_cmd_update_event_mask(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &event_mask : info->event_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -910,7 +910,7 @@ static int diag_cmd_toggle_events(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &event_mask : info->event_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -965,7 +965,7 @@ static int diag_cmd_get_log_mask(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &log_mask : info->log_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -1047,7 +1047,7 @@ static int diag_cmd_get_log_range(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &log_mask : info->log_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -1091,7 +1091,7 @@ static int diag_cmd_set_log_mask(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &log_mask : info->log_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
@@ -1211,7 +1211,7 @@ static int diag_cmd_disable_log_mask(unsigned char *src_buf, int src_len,
        mask_info = (!info) ? &log_mask : info->log_mask;
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0 ||
            !mask_info) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d, mask_info: %p\n",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d, mask_info: %pK\n",
                       __func__, src_buf, src_len, dest_buf, dest_len,
                       mask_info);
                return -EINVAL;
index 7bc5bb1..da5a477 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -158,7 +158,7 @@ int diag_md_write(int id, unsigned char *buf, int len, int ctx)
                if (ch->tbl[i].buf != buf)
                        continue;
                found = 1;
-               pr_err_ratelimited("diag: trying to write the same buffer buf: %p, ctxt: %d len: %d at i: %d back to the table, proc: %d, mode: %d\n",
+               pr_err_ratelimited("diag: trying to write the same buffer buf: %pK, ctxt: %d len: %d at i: %d back to the table, proc: %d, mode: %d\n",
                                   buf, ctx, ch->tbl[i].len,
                                   i, id, driver->logging_mode);
        }
index 2f47691..eb715cc 100644 (file)
@@ -132,7 +132,7 @@ static void diag_usb_buf_tbl_remove(struct diag_usb_info *usb_info,
        list_for_each_safe(start, temp, &usb_info->buf_tbl) {
                entry = list_entry(start, struct diag_usb_buf_tbl_t, track);
                if (entry->buf == buf) {
-                       DIAG_LOG(DIAG_DEBUG_MUX, "ref_count-- for %p\n", buf);
+                       DIAG_LOG(DIAG_DEBUG_MUX, "ref_count-- for %pK\n", buf);
                        atomic_dec(&entry->ref_count);
                        /*
                         * Remove reference from the table if it is the
@@ -155,7 +155,7 @@ static struct diag_usb_buf_tbl_t *diag_usb_buf_tbl_get(
        list_for_each_safe(start, temp, &usb_info->buf_tbl) {
                entry = list_entry(start, struct diag_usb_buf_tbl_t, track);
                if (entry->buf == buf) {
-                       DIAG_LOG(DIAG_DEBUG_MUX, "ref_count-- for %p\n", buf);
+                       DIAG_LOG(DIAG_DEBUG_MUX, "ref_count-- for %pK\n", buf);
                        atomic_dec(&entry->ref_count);
                        return entry;
                }
@@ -303,7 +303,7 @@ static void diag_usb_write_done(struct diag_usb_info *ch,
        ch->write_cnt++;
        entry = diag_usb_buf_tbl_get(ch, req->context);
        if (!entry) {
-               pr_err_ratelimited("diag: In %s, unable to find entry %p in the table\n",
+               pr_err_ratelimited("diag: In %s, unable to find entry %pK in the table\n",
                                   __func__, req->context);
                return;
        }
@@ -398,7 +398,7 @@ static int diag_usb_write_ext(struct diag_usb_info *usb_info,
        struct diag_request *req = NULL;
 
        if (!usb_info || !buf || len <= 0) {
-               pr_err_ratelimited("diag: In %s, usb_info: %p buf: %p, len: %d\n",
+               pr_err_ratelimited("diag: In %s, usb_info: %pK buf: %pK, len: %d\n",
                                   __func__, usb_info, buf, len);
                return -EINVAL;
        }
@@ -518,7 +518,8 @@ int diag_usb_write(int id, unsigned char *buf, int len, int ctxt)
 
        spin_lock_irqsave(&usb_info->write_lock, flags);
        if (diag_usb_buf_tbl_add(usb_info, buf, len, ctxt)) {
-               DIAG_LOG(DIAG_DEBUG_MUX, "ERR! unable to add buf %p to table\n",
+               DIAG_LOG(DIAG_DEBUG_MUX,
+                                       "ERR! unable to add buf %pK to table\n",
                         buf);
                diagmem_free(driver, req, usb_info->mempool);
                spin_unlock_irqrestore(&usb_info->write_lock, flags);
index 3b092b8..c6e57f3 100644 (file)
@@ -959,7 +959,7 @@ static int diag_process_userspace_remote(int proc, void *buf, int len)
        int bridge_index = proc - 1;
 
        if (!buf || len < 0) {
-               pr_err("diag: Invalid input in %s, buf: %p, len: %d\n",
+               pr_err("diag: Invalid input in %s, buf: %pK, len: %d\n",
                       __func__, buf, len);
                return -EINVAL;
        }
@@ -2175,7 +2175,7 @@ static int diag_process_apps_data_hdlc(unsigned char *buf, int len,
        const uint32_t max_encoded_size = ((2 * len) + 3);
 
        if (!buf || len <= 0) {
-               pr_err("diag: In %s, invalid buf: %p len: %d\n",
+               pr_err("diag: In %s, invalid buf: %pK len: %d\n",
                       __func__, buf, len);
                return -EIO;
        }
@@ -2294,7 +2294,7 @@ static int diag_process_apps_data_non_hdlc(unsigned char *buf, int len,
        const uint32_t max_pkt_size = sizeof(header) + len + 1;
 
        if (!buf || len <= 0) {
-               pr_err("diag: In %s, invalid buf: %p len: %d\n",
+               pr_err("diag: In %s, invalid buf: %pK len: %d\n",
                       __func__, buf, len);
                return -EIO;
        }
@@ -2365,7 +2365,7 @@ static int diag_user_process_dci_data(const char __user *buf, int len)
        unsigned char *user_space_data = NULL;
 
        if (!buf || len <= 0 || len > diag_mempools[mempool].itemsize) {
-               pr_err_ratelimited("diag: In %s, invalid buf %p len: %d\n",
+               pr_err_ratelimited("diag: In %s, invalid buf %pK len: %d\n",
                                   __func__, buf, len);
                return -EBADMSG;
        }
@@ -2397,7 +2397,7 @@ static int diag_user_process_dci_apps_data(const char __user *buf, int len,
        unsigned char *user_space_data = NULL;
 
        if (!buf || len <= 0 || len > diag_mempools[mempool].itemsize) {
-               pr_err_ratelimited("diag: In %s, invalid buf %p len: %d\n",
+               pr_err_ratelimited("diag: In %s, invalid buf %pK len: %d\n",
                                   __func__, buf, len);
                return -EBADMSG;
        }
@@ -2438,7 +2438,7 @@ static int diag_user_process_raw_data(const char __user *buf, int len)
        struct diag_md_session_t *info = NULL;
 
        if (!buf || len <= 0 || len > CALLBACK_BUF_SIZE) {
-               pr_err_ratelimited("diag: In %s, invalid buf %p len: %d\n",
+               pr_err_ratelimited("diag: In %s, invalid buf %pK len: %d\n",
                                   __func__, buf, len);
                return -EBADMSG;
        }
@@ -2508,7 +2508,7 @@ static int diag_user_process_userspace_data(const char __user *buf, int len)
        uint8_t hdlc_disabled;
 
        if (!buf || len <= 0 || len > USER_SPACE_DATA) {
-               pr_err_ratelimited("diag: In %s, invalid buf %p len: %d\n",
+               pr_err_ratelimited("diag: In %s, invalid buf %pK len: %d\n",
                                   __func__, buf, len);
                return -EBADMSG;
        }
@@ -2597,7 +2597,7 @@ static int diag_user_process_apps_data(const char __user *buf, int len,
        uint8_t hdlc_disabled;
 
        if (!buf || len <= 0 || len > DIAG_MAX_RSP_SIZE) {
-               pr_err_ratelimited("diag: In %s, invalid buf %p len: %d\n",
+               pr_err_ratelimited("diag: In %s, invalid buf %pK len: %d\n",
                                   __func__, buf, len);
                return -EBADMSG;
        }
index ced4bde..aa394f5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2008-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -404,7 +404,7 @@ void diag_update_pkt_buffer(unsigned char *buf, uint32_t len, int type)
        uint32_t max_len = 0;
 
        if (!buf || len == 0) {
-               pr_err("diag: In %s, Invalid ptr %p and length %d\n",
+               pr_err("diag: In %s, Invalid ptr %pK and length %d\n",
                       __func__, buf, len);
                return;
        }
@@ -523,7 +523,7 @@ int diag_process_stm_cmd(unsigned char *buf, unsigned char *dest_buf)
        int i;
 
        if (!buf || !dest_buf) {
-               pr_err("diag: Invalid pointers buf: %p, dest_buf %p in %s\n",
+               pr_err("diag: Invalid pointers buf: %pK, dest_buf %pK in %s\n",
                       buf, dest_buf, __func__);
                return -EIO;
        }
@@ -612,7 +612,7 @@ int diag_process_time_sync_query_cmd(unsigned char *src_buf, int src_len,
        struct diag_cmd_time_sync_query_rsp_t rsp;
 
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d",
                        __func__, src_buf, src_len, dest_buf, dest_len);
                return -EINVAL;
        }
@@ -639,7 +639,7 @@ int diag_process_time_sync_switch_cmd(unsigned char *src_buf, int src_len,
        int err = 0, write_len = 0;
 
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d",
                        __func__, src_buf, src_len, dest_buf, dest_len);
                return -EINVAL;
        }
@@ -711,7 +711,7 @@ int diag_cmd_log_on_demand(unsigned char *src_buf, int src_len,
                return 0;
 
        if (!src_buf || !dest_buf || src_len <= 0 || dest_len <= 0) {
-               pr_err("diag: Invalid input in %s, src_buf: %p, src_len: %d, dest_buf: %p, dest_len: %d",
+               pr_err("diag: Invalid input in %s, src_buf: %pK, src_len: %d, dest_buf: %pK, dest_len: %d",
                       __func__, src_buf, src_len, dest_buf, dest_len);
                return -EINVAL;
        }
index 038740d..701677b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -142,7 +142,7 @@ int diagfwd_bridge_register(int id, int ctxt, struct diag_remote_dev_ops *ops)
        char wq_name[DIAG_BRIDGE_NAME_SZ + 10];
 
        if (!ops) {
-               pr_err("diag: Invalid pointers ops: %p ctxt: %d\n", ops, ctxt);
+               pr_err("diag: Invalid pointers ops: %pK ctxt: %d\n", ops, ctxt);
                return -EINVAL;
        }
 
index 987931f..5fed1f8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, 2016 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -354,7 +354,7 @@ static int hsic_write(int id, unsigned char *buf, int len, int ctxt)
                return -EINVAL;
        }
        if (!buf || len <= 0) {
-               pr_err_ratelimited("diag: In %s, ch %d, invalid buf %p len %d\n",
+               pr_err_ratelimited("diag: In %s, ch %d, invalid buf %pK len %d\n",
                                   __func__, id, buf, len);
                return -EINVAL;
        }
index a35d5c7..b8ed216 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -131,8 +131,6 @@ static int mhi_buf_tbl_add(struct diag_mhi_info *mhi_info, int type,
 
        item = kzalloc(sizeof(struct diag_mhi_buf_tbl_t), GFP_KERNEL);
        if (!item) {
-               pr_err_ratelimited("diag: In %s, unable to allocate new item for buf tbl, ch: %p, type: %d, buf: %p, len: %d\n",
-                                  __func__, ch, ch->type, buf, len);
                return -ENOMEM;
        }
        kmemleak_not_leak(item);
@@ -185,7 +183,7 @@ static void mhi_buf_tbl_remove(struct diag_mhi_info *mhi_info, int type,
        spin_unlock_irqrestore(&ch->lock, flags);
 
        if (!found) {
-               pr_err_ratelimited("diag: In %s, unable to find buffer, ch: %p, type: %d, buf: %p\n",
+               pr_err_ratelimited("diag: In %s, unable to find buffer, ch: %pK, type: %d, buf: %pK\n",
                                   __func__, ch, ch->type, buf);
        }
 }
@@ -398,7 +396,7 @@ static void mhi_read_done_work_fn(struct work_struct *work)
                if (!buf)
                        break;
                DIAG_LOG(DIAG_DEBUG_BRIDGE,
-                        "read from mhi port %d buf %p\n",
+                        "read from mhi port %d buf %pK\n",
                         mhi_info->id, buf);
                /*
                 * The read buffers can come after the MHI channels are closed.
@@ -444,7 +442,7 @@ static void mhi_read_work_fn(struct work_struct *work)
                        goto fail;
 
                DIAG_LOG(DIAG_DEBUG_BRIDGE,
-                        "queueing a read buf %p, ch: %s\n",
+                        "queueing a read buf %pK, ch: %s\n",
                         buf, mhi_info->name);
                spin_lock_irqsave(&read_ch->lock, flags);
                err = mhi_queue_xfer(read_ch->hdl, buf, DIAG_MDM_BUF_SIZE,
@@ -488,7 +486,7 @@ static int mhi_write(int id, unsigned char *buf, int len, int ctxt)
        }
 
        if (!buf || len <= 0) {
-               pr_err("diag: In %s, ch %d, invalid buf %p len %d\n",
+               pr_err("diag: In %s, ch %d, invalid buf %pK len %d\n",
                        __func__, id, buf, len);
                return -EINVAL;
        }
@@ -515,7 +513,7 @@ static int mhi_write(int id, unsigned char *buf, int len, int ctxt)
        err = mhi_queue_xfer(ch->hdl, buf, len, mhi_flags);
        spin_unlock_irqrestore(&ch->lock, flags);
        if (err) {
-               pr_err_ratelimited("diag: In %s, cannot write to MHI channel %p, len %d, err: %d\n",
+               pr_err_ratelimited("diag: In %s, cannot write to MHI channel %pK, len %d, err: %d\n",
                                   __func__, diag_mhi[id].name, len, err);
                mhi_buf_tbl_remove(&diag_mhi[id], TYPE_MHI_WRITE_CH, buf, len);
                goto fail;
index 8e2d146..755c8fa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -254,7 +254,7 @@ static void diagfwd_data_read_done(struct diagfwd_info *fwd_info,
                        temp_buf = fwd_info->buf_2;
                        write_buf = fwd_info->buf_2->data;
                } else {
-                       pr_err("diag: In %s, no match for buffer %p, peripheral %d, type: %d\n",
+                       pr_err("diag: In %s, no match for buffer %pK, peripheral %d, type: %d\n",
                               __func__, buf, fwd_info->peripheral,
                               fwd_info->type);
                        goto end;
@@ -268,7 +268,7 @@ static void diagfwd_data_read_done(struct diagfwd_info *fwd_info,
                           fwd_info->buf_2->data_raw == buf) {
                        temp_buf = fwd_info->buf_2;
                } else {
-                       pr_err("diag: In %s, no match for non encode buffer %p, peripheral %d, type: %d\n",
+                       pr_err("diag: In %s, no match for non encode buffer %pK, peripheral %d, type: %d\n",
                               __func__, buf, fwd_info->peripheral,
                               fwd_info->type);
                        goto end;
@@ -288,7 +288,7 @@ static void diagfwd_data_read_done(struct diagfwd_info *fwd_info,
                           fwd_info->buf_2->data_raw == buf) {
                        temp_buf = fwd_info->buf_2;
                } else {
-                       pr_err("diag: In %s, no match for non encode buffer %p, peripheral %d, type: %d\n",
+                       pr_err("diag: In %s, no match for non encode buffer %pK, peripheral %d, type: %d\n",
                                __func__, buf, fwd_info->peripheral,
                                fwd_info->type);
                        goto end;
@@ -943,7 +943,7 @@ void diagfwd_channel_read(struct diagfwd_info *fwd_info)
        if (!(fwd_info->p_ops && fwd_info->p_ops->read && fwd_info->ctxt))
                goto fail_return;
 
-       DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "issued a read p: %d t: %d buf: %p\n",
+       DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "issued a read p: %d t: %d buf: %pK\n",
                 fwd_info->peripheral, fwd_info->type, read_buf);
        err = fwd_info->p_ops->read(fwd_info->ctxt, read_buf, read_len);
        if (err)
index 3686cf6..3ee2110 100644 (file)
@@ -438,7 +438,7 @@ void diag_smd_invalidate(void *ctxt, struct diagfwd_info *fwd_ctxt)
        smd_info = (struct diag_smd_info *)ctxt;
        prev = smd_info->fwd_ctxt;
        smd_info->fwd_ctxt = fwd_ctxt;
-       DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s prev: %p fwd_ctxt: %p\n",
+       DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s prev: %pK fwd_ctxt: %pK\n",
                 smd_info->name, prev, smd_info->fwd_ctxt);
 }
 
@@ -467,7 +467,7 @@ static void __diag_smd_init(struct diag_smd_info *smd_info)
        atomic_set(&smd_info->opened, 0);
        atomic_set(&smd_info->diag_state, 0);
 
-       DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s initialized fwd_ctxt: %p\n",
+       DIAG_LOG(DIAG_DEBUG_PERIPHERALS, "%s initialized fwd_ctxt: %pK\n",
                 smd_info->name, smd_info->fwd_ctxt);
 }
 
@@ -599,7 +599,7 @@ static int diag_smd_write_ext(struct diag_smd_info *smd_info,
        uint8_t avail = 0;
 
        if (!smd_info || !buf || len <= 0) {
-               pr_err_ratelimited("diag: In %s, invalid params, smd_info: %p, buf: %p, len: %d\n",
+               pr_err_ratelimited("diag: In %s, invalid params, smd_info: %pK, buf: %pK, len: %d\n",
                                   __func__, smd_info, buf, len);
                return -EINVAL;
        }
@@ -671,7 +671,7 @@ static int diag_smd_write(void *ctxt, unsigned char *buf, int len)
 
        smd_info = (struct diag_smd_info *)ctxt;
        if (!smd_info || !buf || len <= 0) {
-               pr_err_ratelimited("diag: In %s, invalid params, smd_info: %p, buf: %p, len: %d\n",
+               pr_err_ratelimited("diag: In %s, invalid params, smd_info: %pK, buf: %pK, len: %d\n",
                                   __func__, smd_info, buf, len);
                return -EINVAL;
        }
@@ -753,7 +753,7 @@ static int diag_smd_read(void *ctxt, unsigned char *buf, int buf_len)
 
        if (!smd_info->hdl || !atomic_read(&smd_info->opened)) {
                DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
-                        "%s stopping read, hdl: %p, opened: %d\n",
+                        "%s stopping read, hdl: %pK, opened: %d\n",
                         smd_info->name, smd_info->hdl,
                         atomic_read(&smd_info->opened));
                goto fail_return;
index f379261..18f76ea 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -249,7 +249,7 @@ static void socket_data_ready(struct sock *sk_ptr)
 static void cntl_socket_data_ready(struct sock *sk_ptr)
 {
        if (!sk_ptr || !cntl_socket) {
-               pr_err_ratelimited("diag: In %s, invalid ptrs. sk_ptr: %p cntl_socket: %p\n",
+               pr_err_ratelimited("diag: In %s, invalid ptrs. sk_ptr: %pK cntl_socket: %pK\n",
                                   __func__, sk_ptr, cntl_socket);
                return;
        }