Commit 012a6ef
ASoC: sma1307: Fix error handling in sma1307_setting_loaded()
There are a couple bugs in this code:
1) The cleanup code calls kfree(sma1307->set.header) and
kfree(sma1307->set.def) but those functions were allocated using
devm_kzalloc(). It results in a double free. Delete all these
kfree() calls.
2) A missing call to kfree(data) if the checksum was wrong on this error
path:
if ((sma1307->set.checksum >> 8) != SMA1307_SETTING_CHECKSUM) {
Since the "data" pointer is supposed to be freed on every return, I
changed that to use the __free(kfree) cleanup attribute.
Fixes: 0ec6bd1 ("ASoC: sma1307: Add NULL check in sma1307_setting_loaded()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/8d32dd96-1404-4373-9b6c-c612a9c18c4c@stanley.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>1 parent 2593f7e commit 012a6ef
1 file changed
Lines changed: 2 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1705 | 1705 | | |
1706 | 1706 | | |
1707 | 1707 | | |
1708 | | - | |
| 1708 | + | |
1709 | 1709 | | |
1710 | 1710 | | |
1711 | 1711 | | |
| |||
1722 | 1722 | | |
1723 | 1723 | | |
1724 | 1724 | | |
1725 | | - | |
| 1725 | + | |
1726 | 1726 | | |
1727 | 1727 | | |
1728 | 1728 | | |
| |||
1742 | 1742 | | |
1743 | 1743 | | |
1744 | 1744 | | |
1745 | | - | |
1746 | 1745 | | |
1747 | 1746 | | |
1748 | 1747 | | |
| |||
1763 | 1762 | | |
1764 | 1763 | | |
1765 | 1764 | | |
1766 | | - | |
1767 | | - | |
1768 | 1765 | | |
1769 | 1766 | | |
1770 | 1767 | | |
| |||
1782 | 1779 | | |
1783 | 1780 | | |
1784 | 1781 | | |
1785 | | - | |
1786 | | - | |
1787 | | - | |
1788 | 1782 | | |
1789 | 1783 | | |
1790 | 1784 | | |
| |||
1799 | 1793 | | |
1800 | 1794 | | |
1801 | 1795 | | |
1802 | | - | |
1803 | 1796 | | |
1804 | 1797 | | |
1805 | 1798 | | |
| |||
0 commit comments