Commit Graph

72 Commits (060f0ce6ff975decd1e0ee318c08e228bccbee1e)

Author SHA1 Message Date
Dan Carpenter cb9cc9cae9 Staging: bcm: copying more data than intended
This was changed to bcm_flash2x_cs_info instead of bcm_flash_cs_info
when we got rid of the typedefs.  bcm_flash2x_cs_info is quite a bit
larger than bcm_flash_cs_info (436 bytes instead of 96) so it would
corrupt user memory and it's an info leak.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17 13:52:37 -08:00
Kevin McKinney a049728928 Staging: bcm: Change the name of typedef USER_BCM_DBG_STATE to bcm_user_debug_state.
This patch removes typedef for USER_BCM_DBG_STATE, and
changes the name of the struct to bcm_user_debug_state.
In addition, any calls to struct "USER_BCM_DBG_STATE"
are changed to call directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:57:51 -08:00
Kevin McKinney a23e67f1a2 Staging: bcm: Remove typedef for _LINK_STATE and call directly.
This patch removes typedef for _LINK_STATE, and changes
the name of the struct to bcm_link_state. In addition,
any calls to struct "LINK_STATE, or PLINK_STATE" are
changed to call directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:56:43 -08:00
Kevin McKinney 168b14009a Staging: bcm: Remove typedef for _FLASH_CS_INFO and call directly.
This patch removes typedef for _FLASH_CS_INFO, and
changes the name of the struct to bcm_flash_cs_info.
In addition, any calls to typedefs FLASH_CS_INFO, or
*PFLASH_CS_INFO are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:45:51 -08:00
Kevin McKinney 08391731e0 Staging: bcm: Remove typedef for _FLASH_2X_CS_INFO and call directly.
This patch removes typedef for _FLASH_2X_CS_INFO, and
changes the name of the struct to bcm_flash2x_cs_info.
In addition, any calls to typedefs FLASH2X_CS_INFO, or
*PFLASH2X_CS_INFO are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:45:51 -08:00
Kevin McKinney 954f91d1af Staging: bcm: Remove typedef for _S_MIBS_HOST_STATS_MIBS and call directly.
This patch removes typedef for _S_MIBS_HOST_STATS_MIBS,
and changes the name of the struct to bcm_host_stats_mibs.
In addition, any calls to typedefs S_MIBS_HOST_STATS_MIBS
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:07:57 -08:00
Kevin McKinney dc23445a11 Staging: bcm: Remove typedef for rdmbuffer and call directly.
This patch removes typedef for rdmbuffer, and
changes the name of the struct to bcm_rdm_buffer.
In addition, any calls to typedefs RDM_BUFFER, or
*PRDM_BUFFER are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:23 -08:00
Kevin McKinney a2521d7971 Staging: bcm: Remove typedef for wrmbuffer and call directly.
This patch removes typedef for wrmbuffer, and
changes the name of the struct to bcm_wrm_buffer.
In addition, any calls to typedefs WRM_BUFFER, or
*PWRM_BUFFER are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:23 -08:00
Kevin McKinney 86d289d257 Staging: bcm: Remove typedef for stGPIOInfo and call directly.
This patch removes typedef for stGPIOInfo, and
changes the name of the struct to bcm_gpio_info.
In addition, any calls to typedefs GPIO_INFO, or
*PGPIO_INFO are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:23 -08:00
Kevin McKinney bac02ed8a7 Staging: bcm: Remove typedef for ioctlbuffer and call directly.
This patch removes typedef for ioctlbuffer, and
changes the name of the struct to bcm_ioctl_buffer.
In addition, any calls to typedefs IOCTL_BUFFER, or
*PIOCTL_BUFFER are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:22 -08:00
Kevin McKinney d532703c38 Staging: bcm: Remove typedef for stUserThreadReq and call directly.
This patch removes typedef for stUserThreadReq,
and changes the name of the struct to bcm_user_thread_req.
In addition, any calls to typedefs USER_THREAD_REQ, or
*PUSER_THREAD_REQ are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:22 -08:00
Kevin McKinney ff4e065de1 Staging: bcm: Remove typedef for _FLASH2X_SECTION_VAL and reference directly.
This patch removes typedef for _FLASH2X_SECTION_VAL,
and changes the name of the enum to bcm_flash2x_section_val.
In addition, any calls to typedefs FLASH2X_SECTION_VAL
are changed to reference the enum directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:22 -08:00
Kevin McKinney ff31e745cd Staging: bcm: Remove typedef for _DEVICE_DRIVER_INFO and call directly.
This patch removes typedef for _DEVICE_DRIVER_INFO,
and changes the name of the struct to
bcm_driver_info. In addition, any calls to
typedefs DEVICE_DRIVER_INFO are changed to call
the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:22 -08:00
Kevin McKinney b4a29e104a Staging: bcm: Remove typedef for _FLASH2X_READWRITE and call directly.
This patch removes typedef for _FLASH2X_READWRITE,
and changes the name of the struct to
bcm_flash2x_readwrite. In addition, any calls to
typedefs FLASH2X_READWRITE, or *PFLASH2X_READWRITE
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:22 -08:00
Kevin McKinney 3712af0c0d Staging: bcm: Remove typedef for _NVM_READWRITE and call directly.
This patch removes typedef for _NVM_READWRITE,
and changes the name of the struct to
bcm_nvm_readwrite. In addition, any calls to
typedefs NVM_READWRITE, or *PNVM_READWRITE
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:22 -08:00
Kevin McKinney 98e341d3dd Staging: bcm: Remove typedef for bulkwrmbuffer and call directly.
This patch removes typedef for bulkwrmbuffer,
and changes the name of the struct to
bcm_bulk_wrm_buffer. In addition, any calls to
typedefs BULKWRM_BUFFER, or *PBULKWRM_BUFFER
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:22 -08:00
Kevin McKinney b1206c091b Staging: bcm: Remove typedef for _FLASH2X_COPY_SECTION and call directly.
This patch removes typedef for _FLASH2X_COPY_SECTION,
and changes the name of the struct to
bcm_flash2x_copy_section. In addition, any calls to
typedefs FLASH2X_COPY_SECTION, or *PFLASH2X_COPY_SECTION
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:21 -08:00
Kevin McKinney d48a430c2c Staging: bcm: Remove typedef for _FLASH2X_BITMAP and call directly.
This patch removes typedef for _FLASH2X_BITMAP,
and changes the name of the struct to
bcm_flash2x_bitmap. In addition, any calls
to typedefs FLASH2X_BITMAP, or *PFLASH2X_BITMAP
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:14 -08:00
Kevin McKinney 0395a61d91 Staging: bcm: Remove typedef for _ST_TIME_ELAPSED_ and call directly.
This patch removes typedef for _ST_TIME_ELAPSED_,
and changes the name of the struct to
bcm_time_elapsed. In addition, any calls
to typedefs ST_TIME_ELAPSED, or *PST_TIME_ELAPSED
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:12 -08:00
Kevin McKinney 63df64a27a Staging: bcm: Remove typedef for stGPIOMultiInfo and call directly.
This patch removes typedef for stGPIOMultiInfo,
and changes the name of the struct to
bcm_gpio_multi_info. In addition, any calls
to typedefs GPIO_MULTI_INFO, or *PGPIO_MULTI_INFO
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:12 -08:00
Kevin McKinney 9e91edb71d Staging: bcm: Remove typedef for stGPIOMultiMode and call directly.
This patch removes typedef for
stGPIOMultiMode, and changes the name of the
struct to bcm_gpio_multi_mode. In addition,
any calls to typedefs GPIO_MULTI_MODE, or
*PGPIO_MULTI_MODE are changed to call the
struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-26 16:05:12 -08:00
Kevin McKinney d6861cfef2 Staging: bcm: Remove typedef for _S_INTERFACE_ADAPTER and call directly.
This patch removes typedef for
_S_INTERFACE_ADAPTER, changes the
name of the struct to bcm_interface_adapter.
In addition, any calls to typedefs
S_INTERFACE_ADAPTER, or *PS_INTERFACE_ADAPTER
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-02 11:36:46 -07:00
Kevin McKinney 7fac0c47ed Staging: bcm: Remove typedef for stLocalSFAddIndicationAlt and call directly.
This patch removes typedef for
stLocalSFAddIndicationAlt, changes the
name of the struct to bcm_add_indication_alt,
and removes a comment. In addition, any
calls to typedef stLocalSFAddIndicationAlt
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-30 19:44:48 -07:00
Wei Yongjun dce15efebe staging: bcm: fix possible memory leak in bcm_char_ioctl()
psFwInfo has been allocated in this function and should be
freed before leaving from the error handling cases.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-04 14:14:08 -07:00
Kevin McKinney 2979460d7a Staging: bcm: Remove typedef for _MINI_ADAPTER and call directly.
This patch removes typedef for _MINI_ADAPTER, changes the
name of the struct from _MINI_ADAPTER to bcm_mini_adapter.
In addition, any calls to the following typedefs
"MINI_ADAPTER, *PMINI_ADAPTER" are changed to call
the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 21:09:22 -07:00
Kevin McKinney 2610c7a889 Staging: bcm: Remove typedef for link_request and call directly.
This patch removes typedef for link_request, changes the
name of the struct from link_request to bcm_link_request.
In addition, any calls to the following typedefs
"LINK_REQUEST, *PLINK_REQUEST, *CONTROL_MESSAGE"
are changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 21:09:21 -07:00
Kevin McKinney 0b3edf760a Staging: bcm: Remove typedef for _packet_info and call directly.
This patch removes typedef for _packet_info,
changes the name of the struct from
_packet_info to bcm_packet_info.
In addition, any calls to the following typedefs
"PacketInfo, _packet_info" are changed to call the
struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 21:08:10 -07:00
Kevin McKinney 774bea8314 Staging: bcm: Remove typedef for _PER_TARANG_DATA and call directly.
This patch removes typedef for _PER_TARANG_DATA,
changes the name of the struct from
_PER_TARANG_DATA to bcm_per_tarang_data.
In addition, any calls to the following typedefs
"PER_TARANG_DATA, *PPER_TARANG_DATA" are
changed to call the struct directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 21:08:09 -07:00
Kevin McKinney 7a27a2ccf8 Staging: bcm: Remove typedef for FirmwareInfo and call directly.
This patch removes typedef for FirmwareInfo,
changes the name from Firmwareinfo to
bcm_firmware_info. In addition, any calls to
the following typedefs "PFIRMWARE_INFO,
FIRMWARE_INFO" are changed to call the struct
directly.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 21:06:35 -07:00
Thomas Meyer 2d9ebe77b7 Staging: bcm: Use memdup_user rather than duplicating its implementation
This is a little bit restricted to reduce false positives

The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup_user.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-08 17:22:16 -08:00
Kevin McKinney b71dbbcfaa Staging: bcm: Fix an integer overflow in IOCTL_BCM_NVM_READ/WRITE
Variables stNVMReadWrite.uioffset and stNVMReadWrite.uiNumBytes
are chosen from userspace and can be very high. The sum of
these two digits would result in a small number. Therefore,
this patch verifies a negative number was not entered, and
reorganizes the equation to remove the integer overflow.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-08 17:19:03 -08:00
Kevin McKinney 221fd753dd Staging: bcm: Fix an invalid dereference to a kmalloc in IOCTL_BCM_BULK_WRM
Variable IoBuffer.InputLength is chosen from userspace,
and can therefore be less than the intended size. In this
case,the memory from the kmalloc call is eventually cast
to a PBULKWRM_BUFFER. If the IoBuffer.InputLength does not
meet the minimum size of PBULKWRM_BUFFER, then we will get
a kernel Oops. To resolve this issue, this patch verifies
IoBuffer.InputLength meets the minimum size before invoking
the kmalloc call.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-22 13:32:45 -08:00
Kevin McKinney b72a7c859e Staging: bcm: Fix information leak in IOCTL_BCM_GET_DRIVER_VERSION
This ioctl, IOCTL_BCM_GET_DRIVER_VERSION, is
responsible for sending the driver version
to userspace. However, the requested size stored
in IoBuffer.OutputLength may be incorrect.
Therefore, we altered the code to send the
exact length of the version, plus one for the
null character.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-22 13:32:45 -08:00
Kevin McKinney d3a21c3c4b Staging: bcm: Alter return value for copy_to/from_user() to "return -EFAULT" when an error occurs.
In this clean up patch, I altered functions: copy_to/
from_user() to return -EFAULT when an error occurs.
I also replaced break statements when an error occurs
from copy_to/from_user() with direct returns of -EFAULT.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-08 12:42:16 -08:00
Kevin McKinney 6561f91d68 Staging: bcm: Alter code to move error handling closer to the calls; and remove white space, IOCTL_BCM_NVM_WRITE.
This is a clean up patch for IOCTL_BCM_NVM_WRITE
that replaces the assignment of the Status
variable with direct returns of the error code,
replaces the break statements with direct returns,
and removes a white space.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-08 12:42:16 -08:00
Kevin McKinney 09468b0392 Staging: bcm: Fix double free of 'pReadData' in IOCTL_BCM_NVM_WRITE.
This patch fixes a memory error in ioctl,
IOCTL_BCM_NVM_WRITE. While copying data to
user space, if an error occurs, pReadData
is freed. Then, at the end of the ioctl,
pReadData was being freed again.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-12-08 12:42:15 -08:00
Kevin McKinney 19a177e6fb Staging: bcm: Reverse semaphore locking in IOCTL_BCM_BUFFER_DOWNLOAD_STOP.
This patch reorders the semaphore locking.
It makes better sense to first evaluate
fw_download_sema semaphore then
NVMRdmWrmLocl semaphore. The
fw_download_sema is suppose to be
acquired in the START ioctl.  If this is
not true, then it does not make sense
to continue.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-29 10:09:52 +09:00
Kevin McKinney 8fbebb091a Staging: bcm: Alter code to move error handling closer to the calls.
This is a cleanup patch. I've shuffled the code around to
move the error handling closer to the calls. I've removed
some indent levels. I've replaced break statements with
direct returns.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-29 10:09:52 +09:00
Kevin McKinney fef5675ecb Staging: bcm: Clean up patch that calls semaphore down_trylock directly.
This patch evaluates/calls the down_trylock locking
function directly, instead of storing the results
in a variable and evaluating the variable. These
changes were made in:
IOCTL_BCM_BUFFER_DOWNLOAD_STOP and
IOCTL_BCM_BUFFER_DOWNLOAD_START.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-29 10:09:52 +09:00
Kevin McKinney d9f26a6689 Staging: bcm: Fix semaphore locking error when downloading firmware.
This patch releases semaphore locks when
an error occurrs while attempting to
download firmware for the bcm driver.
When downloading firmware for this driver,
a process is expected to call
the following ioctl's in this order:
(1)IOCTL_BCM_BUFFER_DOWNLOAD_START,
(2)IOCTL_BCM_BUFFER_DOWNLOAD, and (3)
IOCTL_BCM_BUFFER_DOWNLOAD_STOP.
Semaphore, “Adapter->fw_download_sema” is
expected to be acquired in the first ioctl,
IOCTL_BCM_BUFFER_DOWNLOAD_START, and it should
block until IOCTL_BCM_BUFFER_DOWNLOAD_STOP
is called.  In this case, if an error
occurred before STOP finished, the semaphore
"Adapter->fw_download_sema" was not being released.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26 17:14:48 -08:00
Kevin McKinney abe33fc093 Staging: bcm: Fix semaphore locking bug in, IOCTL_BCM_BUFFER_DOWNLOAD
In this ioctl, we are testing to see if the lock is held.
If it is not held, that means this ioctl used incorrectly.
Therefore, we do not want to take the lock ourselves here.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26 17:14:48 -08:00
Kevin McKinney 77121d52a4 Staging: bcm: Remove unnecessary "do while" statement in, IOCTL_BCM_BUFFER_DOWNLOAD
This patch removes a superfluous "do while"
statement in IOCTL_BCM_BUFFER_DOWNLOAD.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26 17:14:48 -08:00
Kevin McKinney 51935d2259 Staging: bcm: Clean up code in ioctl: IOCTL_BCM_EEPROM_REGISTER_READ
This patch verifies two conditions before executing
a kmalloc call. First, it checks to see that
IoBuffer.OutputLength is not greater than an
unsigned short. If so, an invalid value may be
returned. The second change is a check to make
sure IoBuffer.OutputLength is not equal to
zero. Which simply keeps this code inline with
the other ioctl, IOCTL_BCM_REGISTER_READ_PRIVATE.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26 17:13:33 -08:00
Kevin McKinney 41c7b7c0fa Staging: bcm: Fix information leak in ioctl: IOCTL_BCM_REGISTER_READ_PRIVATE, IOCTL_BCM_EEPROM_REGISTER_READ
This patch fixes an information leak in ioctl
IOCTL_BCM_REGISTER_READ_PRIVATE and
IOCTL_BCM_EEPROM_REGISTER_READ when determining
the number of bytes to copy to user space.  Function,
usb_control_msg, returns the correct number of
bytes from the hardware.  Instead of using
this value, we were using a value derived from
user space. In this case, this value could be more
than the hardware allocated.  Therefore, this
patch copies the proper number of bytes from
the hardware, and uses this value as the maximum
number of bytes for user space.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-11-26 17:11:58 -08:00
Kevin McKinney 2505aa6ce4 Staging: bcm: Alter LOC for readability/understandability purposes
This patch alters a line of code to make it more readable
and easier to understand. The purpose of the original line
of code was to compute the amount of memory to request from
kmalloc. This mulit-step algorithm was being done in one
line of code, thus making it more difficult to understand.
Therefore, I split this algorithm into three logical steps.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-29 17:34:51 -07:00
Kevin McKinney 0a2cc4977f Staging: bcm: Add min/max restrictions for IOCTL_BCM_REGISTER_READ_PRIVATE
This patch fixes two issues within bcm/Bcmchar.c. The
first condition in the or statement checks if variable
IoBuffer.OutputLength, defined from user space, is
greater than the maximum value allowed for an
unsigned short. IoBuffer.OutputLength is then used
in a kmalloc call to return a pointer to memory. If
this size is greater than an unsigned short, it
becomes useless. The second condition in the or statement
checks if the same variable, IoBuffer.OutputLength is
equal to zero before invoking the kmalloc call. In
this case, if a zero size is sent to kmalloc, a valid
pointer to memory is returned instead of the expected NULL.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-29 17:34:51 -07:00
Kevin McKinney e228b7426e Staging: bcm: Add size maximum size restrictions for IOCTL_IDLE_REQ
In the first alteration, the MAX_CNTL_PKT_SIZE is the
maximum size of the control packet in ->Adapter->txctlpacket[]
which is defined in InitAdapter(). This caps the size of
kmalloc memory allocation. In the second change, this max
cap fixes a potential memory corruption bug when subsequent
memset and memcpy calls are invoked.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-19 10:46:17 -07:00
Kevin McKinney 5ac5bd8754 Staging: bcm: Add size minimum size restrictions for IOCTL_IDLE_REQ
If IoBuffer.InputLength is zero then this will cause an Oops when
we dereference the ZERO_SIZE_PTR.  Or if it's smaller than
sizeof(struct link_request) then we would get memory corruption
when we set ->PLength in CopyBufferToControlPacket().

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-19 10:46:17 -07:00
Kevin McKinney 1dc634772b Staging: bcm: Fix memory leak reported during compile.
This patch fixes a potential memory leak were temp_buff buffer
is not being freed when a certain condition is true.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23 15:20:53 -07:00
Kevin McKinney fbfcdf254d Staging: bcm: Fix a coding style error reported by checkpatch.pl
Tool checkpatch.pl reported the following error: extern struct class *bcm_class;"
declaration not allowed in .c files. Therefore, I move this declaration into
the header "headers.h" file.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23 15:20:52 -07:00