summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorRamaswamy Tummala <Ramaswamy.Tummala@Sun.COM>2009-07-27 13:46:49 -0700
committerRamaswamy Tummala <Ramaswamy.Tummala@Sun.COM>2009-07-27 13:46:49 -0700
commitd080a1d702173d234ce60f710694b227c371ead9 (patch)
treeb717a73afff2e3d120bf6f243f7974ca8e1c8751 /usr
parentfe85ab9952691e9ef3ff79251a63003dcec2413a (diff)
downloadillumos-joyent-d080a1d702173d234ce60f710694b227c371ead9.tar.gz
6860487 ioctl IBNEX_CTL_QUERY_PORT should return ENOENT for invalid port numbers
Diffstat (limited to 'usr')
-rw-r--r--usr/src/uts/common/io/ib/ibnex/ibnex_ioctl.c14
-rw-r--r--usr/src/uts/common/sys/ib/ibnex/ibnex_devctl.h24
2 files changed, 27 insertions, 11 deletions
diff --git a/usr/src/uts/common/io/ib/ibnex/ibnex_ioctl.c b/usr/src/uts/common/io/ib/ibnex/ibnex_ioctl.c
index 11c4fdbafb..8bfad5bb25 100644
--- a/usr/src/uts/common/io/ib/ibnex/ibnex_ioctl.c
+++ b/usr/src/uts/common/io/ib/ibnex/ibnex_ioctl.c
@@ -3117,6 +3117,7 @@ ibnex_ctl_query_hca_port(dev_t dev, int cmd, intptr_t arg, int mode,
ibnex_ctl_query_hca_port_32_t *query_hca_port_32 = NULL;
uint_t sgid_tbl_sz;
uint16_t pkey_tbl_sz;
+ ibt_hca_attr_t hca_attr;
IBTF_DPRINTF_L4("ibnex", "\tctl_query_hca_port: cmd=%x, arg=%p, "
"mode=%x, cred=%p, rval=%p, dev=0x%x", cmd, arg, mode, credp,
@@ -3163,8 +3164,15 @@ ibnex_ctl_query_hca_port(dev_t dev, int cmd, intptr_t arg, int mode,
}
}
- if (query_hca_port->port_num == 0) {
- rv = EINVAL;
+ if (ibt_query_hca_byguid(query_hca_port->hca_guid, &hca_attr) !=
+ IBT_SUCCESS) {
+ rv = ENXIO;
+ goto out;
+ }
+
+ if (query_hca_port->port_num == 0 ||
+ query_hca_port->port_num > hca_attr.hca_nports) {
+ rv = ENOENT;
goto out;
}
@@ -3174,7 +3182,7 @@ ibnex_ctl_query_hca_port(dev_t dev, int cmd, intptr_t arg, int mode,
if (ibt_query_hca_ports_byguid(query_hca_port->hca_guid,
query_hca_port->port_num, &ibt_pi, &nports, &size) != IBT_SUCCESS) {
- rv = EINVAL;
+ rv = ENXIO;
goto out;
}
diff --git a/usr/src/uts/common/sys/ib/ibnex/ibnex_devctl.h b/usr/src/uts/common/sys/ib/ibnex/ibnex_devctl.h
index 2dc49eeb3d..c82b43b5a5 100644
--- a/usr/src/uts/common/sys/ib/ibnex/ibnex_devctl.h
+++ b/usr/src/uts/common/sys/ib/ibnex/ibnex_devctl.h
@@ -161,7 +161,7 @@ typedef struct ibnex_ioctl_data_32 {
* IBNEX_CTL_GET_HCA_LIST
* ======================
*
- * Gets GUIDs for all HCAs in the system
+ * Gets GUIDs of all HCAs in the system
*
* arg - pointer to a structure of type ibnex_ctl_get_hca_list_t
*
@@ -190,9 +190,9 @@ typedef struct ibnex_ioctl_data_32 {
*
* Upon successful return from the IOCTL, hca_info will contain HCA attributes
* for the specified GUID. hca_info.hca_device_path_len will contain the actual
- * string length of the hca device path plus the terminating null character.
- * hca_info.hca_device_path will point to null terminated hca device path
- * string if the caller allocated memory for the hca device path is large
+ * string length of the hca device path plus one (for the terminating null
+ * character). hca_info.hca_device_path will point to null terminated hca device
+ * path string if the caller allocated memory for the hca device path is large
* enough to hold the hca device path and the terminating null character.
* Otherwise hca_info.hca_device_path will be set to NULL.
*
@@ -226,6 +226,14 @@ typedef struct ibnex_ioctl_data_32 {
* port_info.p_pkey_tbl will point to an array containing pkeys. The number of
* pkeys in the array is pkey_tbl_alloc_sz or port_info.p_pkey_tbl_sz
* whichever is smaller.
+ *
+ * Error numbers for the above ioctls upon failure:
+ * EINVAL Invalid parameter passed
+ * EFAULT A fault occurred copying data to or from the user space
+ * to the kernel space.
+ * ENXIO Specified HCA GUID does not exist
+ * ENOENT Specified HCA port does not exist
+ *
*/
@@ -292,8 +300,8 @@ typedef struct ibnex_ctl_hca_info_s {
/*
* hca device path and the length.
- * hca_device_path_len is string length of the actual hca device path
- * plus the terminating null character.
+ * hca_device_path_len contains the string length of the actual hca
+ * device path plus one (for the terminating null character).
*/
char *hca_device_path;
uint_t hca_device_path_len;
@@ -387,8 +395,8 @@ typedef struct ibnex_ctl_hca_info_32_s {
/*
* hca device path and the length.
- * hca_device_path_len is string length of the actual hca device path
- * plus the terminating null character.
+ * hca_device_path_len contains the string length of the actual hca
+ * device path plus one (for the terminating null character).
*/
caddr32_t hca_device_path;
uint_t hca_device_path_len;