Commit 4e4f2f69704be0ae218d91fb827e5a6987fe262f
Committed by
David S. Miller
1 parent
716b31abbd
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
dcbnl: Move dcb app allocation into dcb_app_add()
Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 22 additions and 25 deletions Side-by-side Diff
net/dcb/dcbnl.c
... | ... | @@ -1732,6 +1732,21 @@ |
1732 | 1732 | return NULL; |
1733 | 1733 | } |
1734 | 1734 | |
1735 | +static int dcb_app_add(const struct dcb_app *app, int ifindex) | |
1736 | +{ | |
1737 | + struct dcb_app_type *entry; | |
1738 | + | |
1739 | + entry = kmalloc(sizeof(*entry), GFP_ATOMIC); | |
1740 | + if (!entry) | |
1741 | + return -ENOMEM; | |
1742 | + | |
1743 | + memcpy(&entry->app, app, sizeof(*app)); | |
1744 | + entry->ifindex = ifindex; | |
1745 | + list_add(&entry->list, &dcb_app_list); | |
1746 | + | |
1747 | + return 0; | |
1748 | +} | |
1749 | + | |
1735 | 1750 | /** |
1736 | 1751 | * dcb_getapp - retrieve the DCBX application user priority |
1737 | 1752 | * |
... | ... | @@ -1764,6 +1779,7 @@ |
1764 | 1779 | { |
1765 | 1780 | struct dcb_app_type *itr; |
1766 | 1781 | struct dcb_app_type event; |
1782 | + int err = 0; | |
1767 | 1783 | |
1768 | 1784 | event.ifindex = dev->ifindex; |
1769 | 1785 | memcpy(&event.app, new, sizeof(event.app)); |
1770 | 1786 | |
... | ... | @@ -1782,22 +1798,13 @@ |
1782 | 1798 | goto out; |
1783 | 1799 | } |
1784 | 1800 | /* App type does not exist add new application type */ |
1785 | - if (new->priority) { | |
1786 | - struct dcb_app_type *entry; | |
1787 | - entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC); | |
1788 | - if (!entry) { | |
1789 | - spin_unlock(&dcb_lock); | |
1790 | - return -ENOMEM; | |
1791 | - } | |
1792 | - | |
1793 | - memcpy(&entry->app, new, sizeof(*new)); | |
1794 | - entry->ifindex = dev->ifindex; | |
1795 | - list_add(&entry->list, &dcb_app_list); | |
1796 | - } | |
1801 | + if (new->priority) | |
1802 | + err = dcb_app_add(new, dev->ifindex); | |
1797 | 1803 | out: |
1798 | 1804 | spin_unlock(&dcb_lock); |
1799 | - call_dcbevent_notifiers(DCB_APP_EVENT, &event); | |
1800 | - return 0; | |
1805 | + if (!err) | |
1806 | + call_dcbevent_notifiers(DCB_APP_EVENT, &event); | |
1807 | + return err; | |
1801 | 1808 | } |
1802 | 1809 | EXPORT_SYMBOL(dcb_setapp); |
1803 | 1810 | |
... | ... | @@ -1831,7 +1838,6 @@ |
1831 | 1838 | */ |
1832 | 1839 | int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new) |
1833 | 1840 | { |
1834 | - struct dcb_app_type *entry; | |
1835 | 1841 | struct dcb_app_type event; |
1836 | 1842 | int err = 0; |
1837 | 1843 | |
... | ... | @@ -1847,16 +1853,7 @@ |
1847 | 1853 | goto out; |
1848 | 1854 | } |
1849 | 1855 | |
1850 | - /* App entry does not exist add new entry */ | |
1851 | - entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC); | |
1852 | - if (!entry) { | |
1853 | - err = -ENOMEM; | |
1854 | - goto out; | |
1855 | - } | |
1856 | - | |
1857 | - memcpy(&entry->app, new, sizeof(*new)); | |
1858 | - entry->ifindex = dev->ifindex; | |
1859 | - list_add(&entry->list, &dcb_app_list); | |
1856 | + err = dcb_app_add(new, dev->ifindex); | |
1860 | 1857 | out: |
1861 | 1858 | spin_unlock(&dcb_lock); |
1862 | 1859 | if (!err) |