From: Pan Bian Date: Sat, 3 Dec 2016 09:29:28 +0000 (+0800) Subject: misc: set error code when devm_kstrdup fails X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ddc5c9a37be4517270453ce909d3dfcc8de58230;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git misc: set error code when devm_kstrdup fails In function sram_reserve_regions(), the value of return variable ret should be negative on failures. However, the value of ret may be 0 even if the call to devm_kstrdup() returns a NULL pointer. This patch explicitly assigns "-ENOMEM" to ret on the path that devm_kstrdup() fails. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188651 Signed-off-by: Pan Bian Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index b33ab8ce47ab..07ec2a8a9343 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -249,8 +249,10 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) block->label = devm_kstrdup(sram->dev, label, GFP_KERNEL); - if (!block->label) + if (!block->label) { + ret = -ENOMEM; goto err_chunks; + } dev_dbg(sram->dev, "found %sblock '%s' 0x%x-0x%x\n", block->export ? "exported " : "", block->label,