From patchwork Wed Aug 15 20:42:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 1328631 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C1AC1DFFED for ; Wed, 15 Aug 2012 20:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755918Ab2HOUm3 (ORCPT ); Wed, 15 Aug 2012 16:42:29 -0400 Received: from smtp.ispras.ru ([83.149.198.202]:54952 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754152Ab2HOUm3 (ORCPT ); Wed, 15 Aug 2012 16:42:29 -0400 Received: from hednb.ispras.ru (unknown [83.149.198.253]) by smtp.ispras.ru (Postfix) with ESMTP id DF3485D4031; Thu, 16 Aug 2012 00:06:33 +0400 (MSD) From: Alexey Khoroshilov To: Mauro Carvalho Chehab Cc: Alexey Khoroshilov , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@ispras.ru Subject: [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge() Date: Thu, 16 Aug 2012 00:42:25 +0400 Message-Id: <1345063345-31131-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.7.9.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If pci_register_driver() failed, resources allocated in ddb_class_create() are leaked. The patch fixes it. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/media/dvb/ddbridge/ddbridge-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c index ebf3f05..36aa4e4 100644 --- a/drivers/media/dvb/ddbridge/ddbridge-core.c +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c @@ -1705,7 +1705,11 @@ static __init int module_init_ddbridge(void) "Copyright (C) 2010-11 Digital Devices GmbH\n"); if (ddb_class_create()) return -1; - return pci_register_driver(&ddb_pci_driver); + if (pci_register_driver(&ddb_pci_driver) < 0) { + ddb_class_destroy(); + return -1; + } + return 0; } static __exit void module_exit_ddbridge(void)