forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/8390/pcnet_cs.c
....@@ -289,6 +289,11 @@
289289
290290 virt = ioremap(link->resource[2]->start,
291291 resource_size(link->resource[2]));
292
+ if (unlikely(!virt)) {
293
+ pcmcia_release_window(link, link->resource[2]);
294
+ return NULL;
295
+ }
296
+
292297 for (i = 0; i < NR_INFO; i++) {
293298 pcmcia_map_mem_page(link, link->resource[2],
294299 hw_info[i].offset & ~(resource_size(link->resource[2])-1));
....@@ -1103,7 +1108,7 @@
11031108 switch (cmd) {
11041109 case SIOCGMIIPHY:
11051110 data->phy_id = info->phy_id;
1106
- /* fall through */
1111
+ fallthrough;
11071112 case SIOCGMIIREG: /* Read MII PHY register. */
11081113 data->val_out = mdio_read(mii_addr, data->phy_id, data->reg_num & 0x1f);
11091114 return 0;
....@@ -1173,8 +1178,10 @@
11731178 outb_p(E8390_RREAD+E8390_START, nic_base + PCNET_CMD);
11741179
11751180 insw(nic_base + PCNET_DATAPORT,buf,count>>1);
1176
- if (count & 0x01)
1177
- buf[count-1] = inb(nic_base + PCNET_DATAPORT), xfer_count++;
1181
+ if (count & 0x01) {
1182
+ buf[count-1] = inb(nic_base + PCNET_DATAPORT);
1183
+ xfer_count++;
1184
+ }
11781185
11791186 /* This was for the ALPHA version only, but enough people have been
11801187 encountering problems that it is still here. */
....@@ -1423,6 +1430,11 @@
14231430 /* Try scribbling on the buffer */
14241431 info->base = ioremap(link->resource[3]->start,
14251432 resource_size(link->resource[3]));
1433
+ if (unlikely(!info->base)) {
1434
+ ret = -ENOMEM;
1435
+ goto failed;
1436
+ }
1437
+
14261438 for (i = 0; i < (TX_PAGES<<8); i += 2)
14271439 __raw_writew((i>>1), info->base+offset+i);
14281440 udelay(100);