Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S376962AbdD2Td7 (ORCPT ); Sat, 29 Apr 2017 15:33:59 -0400 Received: from mail.ispras.ru ([83.149.199.45]:57346 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1036450AbdD2Tdx (ORCPT ); Sat, 29 Apr 2017 15:33:53 -0400 From: Alexey Khoroshilov To: Bartlomiej Zolnierkiewicz , Tomi Valkeinen Cc: Alexey Khoroshilov , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] m501fb: don't return zero on failure path in sm501fb_start() Date: Sat, 29 Apr 2017 21:33:39 +0200 Message-Id: <1493494419-3917-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 826 Lines: 25 If fbmem iomemory mapping failed, sm501fb_start() breaks off initialization, deallocates resources, but returns zero. As a result, double deallocation can happen in sm501fb_stop(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/video/fbdev/sm501fb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c index d80bc8a3200f..67e314fdd947 100644 --- a/drivers/video/fbdev/sm501fb.c +++ b/drivers/video/fbdev/sm501fb.c @@ -1600,6 +1600,7 @@ static int sm501fb_start(struct sm501fb_info *info, info->fbmem = ioremap(res->start, resource_size(res)); if (info->fbmem == NULL) { dev_err(dev, "cannot remap framebuffer\n"); + ret = -ENXIO; goto err_mem_res; } -- 2.7.4