diff --git a/drivers/net/mctp/mctp-i2c.c b/drivers/net/mctp/mctp-i2c.c index 365c3dfd4034e1f28c8085f6315988afa82fa58c..baf7afac7857e308025f7256f9b5ed4428a5e5b2 100644 --- a/drivers/net/mctp/mctp-i2c.c +++ b/drivers/net/mctp/mctp-i2c.c @@ -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++; } @@ -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); @@ -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; diff --git a/net/mctp/device.c b/net/mctp/device.c index da13444c632bfd3547f2adca6220a317b3d826a5..f49be882e98e2c814aeeb66e2537fbfff99c16ab 100644 --- a/net/mctp/device.c +++ b/net/mctp/device.c @@ -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) @@ -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; }