Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 164ef7a2 authored by Dave Olson's avatar Dave Olson Committed by Roland Dreier
Browse files

IB/ipath: Fix incorrect use of sizeof on msg buffer (function argument)



Inside a function declared as

    void foo(char bar[512])

the value of sizeof bar is the size of a pointer, not 512.  So avoid
constructions like this by passing the size explicitly.

Also reduce the size of the buffer to 128 bytes (512 was overly generous).

Signed-off-by: default avatarDave Olson <dave.olson@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 62793444
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -453,7 +453,7 @@ static void handle_e_ibstatuschanged(struct ipath_devdata *dd,
}
}


static void handle_supp_msgs(struct ipath_devdata *dd,
static void handle_supp_msgs(struct ipath_devdata *dd,
			     unsigned supp_msgs, char msg[512])
			     unsigned supp_msgs, char *msg, int msgsz)
{
{
	/*
	/*
	 * Print the message unless it's ibc status change only, which
	 * Print the message unless it's ibc status change only, which
@@ -461,7 +461,7 @@ static void handle_supp_msgs(struct ipath_devdata *dd,
	 */
	 */
	if (dd->ipath_lasterror & ~INFINIPATH_E_IBSTATUSCHANGED) {
	if (dd->ipath_lasterror & ~INFINIPATH_E_IBSTATUSCHANGED) {
		int iserr;
		int iserr;
		iserr = ipath_decode_err(msg, sizeof msg,
		iserr = ipath_decode_err(msg, msgsz,
					 dd->ipath_lasterror &
					 dd->ipath_lasterror &
					 ~INFINIPATH_E_IBSTATUSCHANGED);
					 ~INFINIPATH_E_IBSTATUSCHANGED);
		if (dd->ipath_lasterror &
		if (dd->ipath_lasterror &
@@ -492,8 +492,8 @@ static void handle_supp_msgs(struct ipath_devdata *dd,
}
}


static unsigned handle_frequent_errors(struct ipath_devdata *dd,
static unsigned handle_frequent_errors(struct ipath_devdata *dd,
				       ipath_err_t errs, char msg[512],
				       ipath_err_t errs, char *msg,
				       int *noprint)
				       int msgsz, int *noprint)
{
{
	unsigned long nc;
	unsigned long nc;
	static unsigned long nextmsg_time;
	static unsigned long nextmsg_time;
@@ -512,7 +512,7 @@ static unsigned handle_frequent_errors(struct ipath_devdata *dd,
				nextmsg_time = nc + HZ * 3;
				nextmsg_time = nc + HZ * 3;
		}
		}
		else if (supp_msgs) {
		else if (supp_msgs) {
			handle_supp_msgs(dd, supp_msgs, msg);
			handle_supp_msgs(dd, supp_msgs, msg, msgsz);
			supp_msgs = 0;
			supp_msgs = 0;
			nmsgs = 0;
			nmsgs = 0;
		}
		}
@@ -525,14 +525,14 @@ static unsigned handle_frequent_errors(struct ipath_devdata *dd,


static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
{
{
	char msg[512];
	char msg[128];
	u64 ignore_this_time = 0;
	u64 ignore_this_time = 0;
	int i, iserr = 0;
	int i, iserr = 0;
	int chkerrpkts = 0, noprint = 0;
	int chkerrpkts = 0, noprint = 0;
	unsigned supp_msgs;
	unsigned supp_msgs;
	int log_idx;
	int log_idx;


	supp_msgs = handle_frequent_errors(dd, errs, msg, &noprint);
	supp_msgs = handle_frequent_errors(dd, errs, msg, sizeof msg, &noprint);


	/* don't report errors that are masked */
	/* don't report errors that are masked */
	errs &= ~dd->ipath_maskederrs;
	errs &= ~dd->ipath_maskederrs;