mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 17:59:32 +00:00
habanalabs: Fix memory corruption in debugfs
This has to be a long instead of a u32 because we write a long value.
On 64 bit systems, this will cause memory corruption.
Fixes: c216477363
("habanalabs: add debugfs support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
This commit is contained in:
parent
bc75be24fa
commit
eeec23cd32
1 changed files with 4 additions and 4 deletions
|
@ -19,7 +19,7 @@
|
||||||
static struct dentry *hl_debug_root;
|
static struct dentry *hl_debug_root;
|
||||||
|
|
||||||
static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
|
static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
|
||||||
u8 i2c_reg, u32 *val)
|
u8 i2c_reg, long *val)
|
||||||
{
|
{
|
||||||
struct armcp_packet pkt;
|
struct armcp_packet pkt;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -36,7 +36,7 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
|
||||||
pkt.i2c_reg = i2c_reg;
|
pkt.i2c_reg = i2c_reg;
|
||||||
|
|
||||||
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
||||||
0, (long *) val);
|
0, val);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
|
dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
|
||||||
|
@ -827,7 +827,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
|
||||||
struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
|
struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
|
||||||
struct hl_device *hdev = entry->hdev;
|
struct hl_device *hdev = entry->hdev;
|
||||||
char tmp_buf[32];
|
char tmp_buf[32];
|
||||||
u32 val;
|
long val;
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
|
|
||||||
if (*ppos)
|
if (*ppos)
|
||||||
|
@ -842,7 +842,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(tmp_buf, "0x%02x\n", val);
|
sprintf(tmp_buf, "0x%02lx\n", val);
|
||||||
rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
|
rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
|
||||||
strlen(tmp_buf));
|
strlen(tmp_buf));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue