Skip to content

Commit

Permalink
Merge branch 'small-fixes-for-mctp'
Browse files Browse the repository at this point in the history
Matt Johnston says:

====================
Small fixes for MCTP

This series has 3 fixes for MCTP.
====================

Link: https://lore.kernel.org/r/20220225053938.643605-1-matt@codeconstruct.com.au
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Feb 26, 2022
2 parents 23d7433 + 33f5d1a commit 3e120e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions drivers/net/mctp/mctp-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int mctp_i2c_recv(struct mctp_i2c_dev *midev)

if (status == NET_RX_SUCCESS) {
ndev->stats.rx_packets++;
ndev->stats.rx_bytes += skb->len;
ndev->stats.rx_bytes += recvlen;
} else {
ndev->stats.rx_dropped++;
}
Expand Down Expand Up @@ -537,6 +537,9 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
struct mctp_hdr *mhdr;
u8 lldst, llsrc;

if (len > MCTP_I2C_MAXMTU)
return -EMSGSIZE;

lldst = *((u8 *)daddr);
llsrc = *((u8 *)saddr);

Expand All @@ -547,8 +550,6 @@ static int mctp_i2c_header_create(struct sk_buff *skb, struct net_device *dev,
hdr->dest_slave = (lldst << 1) & 0xff;
hdr->command = MCTP_I2C_COMMANDCODE;
hdr->byte_count = len + 1;
if (hdr->byte_count > MCTP_I2C_MAXBLOCK)
return -EMSGSIZE;
hdr->source_slave = ((llsrc << 1) & 0xff) | 0x01;
mhdr->ver = 0x01;

Expand Down
8 changes: 4 additions & 4 deletions net/mctp/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@ static void mctp_unregister(struct net_device *dev)
struct mctp_dev *mdev;

mdev = mctp_dev_get_rtnl(dev);
if (mctp_known(dev) != (bool)mdev) {
if (mdev && !mctp_known(dev)) {
// Sanity check, should match what was set in mctp_register
netdev_warn(dev, "%s: mdev pointer %d but type (%d) match is %d",
__func__, (bool)mdev, mctp_known(dev), dev->type);
netdev_warn(dev, "%s: BUG mctp_ptr set for unknown type %d",
__func__, dev->type);
return;
}
if (!mdev)
Expand All @@ -455,7 +455,7 @@ static int mctp_register(struct net_device *dev)

if (mdev) {
if (!mctp_known(dev))
netdev_warn(dev, "%s: mctp_dev set for unknown type %d",
netdev_warn(dev, "%s: BUG mctp_ptr set for unknown type %d",
__func__, dev->type);
return 0;
}
Expand Down

0 comments on commit 3e120e4

Please sign in to comment.