[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121026124122.GJ20754@mwanda>
Date: Fri, 26 Oct 2012 15:41:22 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Cc: davem@...emloft.net,
"joshua.a.hay@...el.com" <joshua.a.hay@...el.com>,
netdev@...r.kernel.org, gospo@...hat.com, sassmann@...hat.com
Subject: Re: [net-next 07/14] ixgbe: eliminate Smatch warnings in
ixgbe_debugfs.c
On Fri, Oct 26, 2012 at 04:58:15AM -0700, Jeff Kirsher wrote:
> From: "joshua.a.hay@...el.com" <joshua.a.hay@...el.com>
>
> This patch replaces calls to copy_to_user, copy_from_user, and the associated
> logic, with calls to simple_read_from_buffer and simple_write_to_buffer
> respectively. This was done to eliminate warnings generated by the Smatch
> static analysis tool.
There were some bugs, it wasn't just about silencing warnings.
> + buf = kasprintf(GFP_KERNEL, "%s: %s\n",
> + adapter->netdev->name,
> + ixgbe_dbg_reg_ops_buf);
> + if (!buf)
> + return -ENOMEM;
> +
> + if (count < strlen(buf))
> return -ENOSPC;
You need a kfree(buf) here.
> - ixgbe_dbg_reg_ops_buf[count] = '\0';
> + len = simple_write_to_buffer(ixgbe_dbg_reg_ops_buf,
> + sizeof(ixgbe_dbg_reg_ops_buf),
This should be "sizeof(ixgbe_dbg_reg_ops_buf) - 1" to leave space
for the NUL terminator.
> + ppos,
> + buffer,
> + count);
> + ixgbe_dbg_reg_ops_buf[len] = '\0';
simple_write_to_buffer() returns negative error codes so this could
corrupt memory.
> + buf = kasprintf(GFP_KERNEL, "%s: %s\n",
> + adapter->netdev->name,
> + ixgbe_dbg_netdev_ops_buf);
> + if (!buf)
> + return -ENOMEM;
>
> - *ppos = len;
> + if (count < strlen(buf))
> + return -ENOSPC;
Missing kfree().
> - ixgbe_dbg_netdev_ops_buf[count] = '\0';
> + len = simple_write_to_buffer(ixgbe_dbg_netdev_ops_buf,
> + sizeof(ixgbe_dbg_netdev_ops_buf),
> + ppos,
> + buffer,
> + count);
> + ixgbe_dbg_netdev_ops_buf[len] = '\0';
Same issues as before.
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists