From patchwork Tue May 3 02:22:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 8999931 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7797C9F1C1 for ; Tue, 3 May 2016 02:23:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8336220279 for ; Tue, 3 May 2016 02:23:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB1BF200FE for ; Tue, 3 May 2016 02:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932252AbcECCXf (ORCPT ); Mon, 2 May 2016 22:23:35 -0400 Received: from mail.ispras.ru ([83.149.199.45]:42978 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932389AbcECCXe (ORCPT ); Mon, 2 May 2016 22:23:34 -0400 Received: from localhost.localdomain (unknown [85.140.190.96]) by mail.ispras.ru (Postfix) with ESMTPSA id 20061540073; Tue, 3 May 2016 05:23:30 +0300 (MSK) From: Alexey Khoroshilov To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: Alexey Khoroshilov , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] fbdev: fbmem: implement error handling in fbmem_init() Date: Tue, 3 May 2016 05:22:27 +0300 Message-Id: <1462242147-19876-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.9.1 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP fbmem_init() ignores all errors, while fbmem_exit() does not check if deallocating resources are valid. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/video/fbdev/core/fbmem.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 4e73b6f6b1c0..76c1ad96fb37 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1854,17 +1854,31 @@ EXPORT_SYMBOL(fb_set_suspend); static int __init fbmem_init(void) { - proc_create("fb", 0, NULL, &fb_proc_fops); + int ret; + + if (!proc_create("fb", 0, NULL, &fb_proc_fops)) + return -ENOMEM; - if (register_chrdev(FB_MAJOR,"fb",&fb_fops)) + ret = register_chrdev(FB_MAJOR, "fb", &fb_fops); + if (ret) { printk("unable to get major %d for fb devs\n", FB_MAJOR); + goto err_chrdev; + } fb_class = class_create(THIS_MODULE, "graphics"); if (IS_ERR(fb_class)) { - printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class)); + ret = PTR_ERR(fb_class); + pr_warn("Unable to create fb class; errno = %d\n", ret); fb_class = NULL; + goto err_class; } return 0; + +err_class: + unregister_chrdev(FB_MAJOR, "fb"); +err_chrdev: + remove_proc_entry("fb", NULL); + return ret; } #ifdef MODULE