mmc: dw_mmc: nexell: use snprintf function
authorChanho Park <chanho61.park@samsung.com>
Wed, 10 Jan 2018 05:37:48 +0000 (14:37 +0900)
committerChanho Park <chanho61.park@samsung.com>
Thu, 11 Jan 2018 12:13:37 +0000 (21:13 +0900)
This patch converts the sprintf function to the snprintf function to
detect buffer overflow.

Change-Id: Ic962a5f9e36cab11de83d4e1887bf74129358dd4
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
drivers/mmc/nexell_dw_mmc.c

index 546e7e79002782d6a7ebae28b50fa3e9a65c5fdf..703bbc0e55cbfe560c9882bbe62f6dc63a4c4c29 100644 (file)
@@ -101,7 +101,7 @@ static unsigned int dw_mci_get_clk(struct dwmci_host *host, uint freq)
        int index = host->dev_index;
        char name[50] = {0, };
 
-       sprintf(name, "%s.%d", DEV_NAME_SDHC, index);
+       snprintf(name, sizeof(name), "%s.%d", DEV_NAME_SDHC, index);
        clk = clk_get((const char *)name);
        if (!clk)
                return 0;
@@ -114,7 +114,7 @@ static unsigned long dw_mci_set_clk(int dev_index, unsigned  rate)
        struct clk *clk;
        char name[50];
 
-       sprintf(name, "%s.%d", DEV_NAME_SDHC, dev_index);
+       snprintf(name, sizeof(name), "%s.%d", DEV_NAME_SDHC, dev_index);
        clk = clk_get((const char *)name);
        if (!clk)
                return 0;