Skip to content

Commit 644d0a5

Browse files
lztomarckleinebudde
authored andcommitted
can: c_can: fix null-ptr-deref on ioctl()
The pdev maybe not a platform device, e.g. c_can_pci device, in this case, calling to_platform_device() would not make sense. Also, per the comment in drivers/net/can/c_can/c_can_ethtool.c, @bus_info should match dev_name() string, so I am replacing this with dev_name() to fix this issue. [ 1.458583] BUG: unable to handle page fault for address: 0000000100000000 [ 1.460921] RIP: 0010:strnlen+0x1a/0x30 [ 1.466336] ? c_can_get_drvinfo+0x65/0xb0 [c_can] [ 1.466597] ethtool_get_drvinfo+0xae/0x360 [ 1.466826] dev_ethtool+0x10f8/0x2970 [ 1.467880] sock_ioctl+0xef/0x300 Fixes: 2722ac9 ("can: c_can: add ethtool support") Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] # 5.14+ Signed-off-by: Tong Zhang <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 54d7a47 commit 644d0a5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/net/can/c_can/c_can_ethtool.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ static void c_can_get_drvinfo(struct net_device *netdev,
1515
struct ethtool_drvinfo *info)
1616
{
1717
struct c_can_priv *priv = netdev_priv(netdev);
18-
struct platform_device *pdev = to_platform_device(priv->device);
19-
2018
strscpy(info->driver, "c_can", sizeof(info->driver));
21-
strscpy(info->bus_info, pdev->name, sizeof(info->bus_info));
19+
strscpy(info->bus_info, dev_name(priv->device), sizeof(info->bus_info));
2220
}
2321

2422
static void c_can_get_ringparam(struct net_device *netdev,

0 commit comments

Comments
 (0)