Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752285AbcDFRRT (ORCPT ); Wed, 6 Apr 2016 13:17:19 -0400 Received: from SMTP.ANDREW.CMU.EDU ([128.2.157.37]:55853 "EHLO smtp.andrew.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751776AbcDFRRS (ORCPT ); Wed, 6 Apr 2016 13:17:18 -0400 Date: Wed, 6 Apr 2016 13:16:46 -0400 From: "Gabriel L. Somlo" To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andreas Ziegler , Valentin Rothberg Subject: Re: [PATCH] qemu_fw_cfg: don't leak kobj on init error Message-ID: <20160406171646.GP2060@HEDWIG.INI.CMU.EDU> References: <1459686193-29414-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459686193-29414-1-git-send-email-mst@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.24 (2015-08-30) X-PMX-Version: 6.3.0.2556906, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.4.6.170916 X-SMTP-Spam-Clean: 8% ( MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1200_1299 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, FROM_EDU_TLD 0, NO_URI_HTTPS 0, REFERENCES 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CT 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0) X-SMTP-Spam-Score: 8% Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1172 Lines: 41 On Sun, Apr 03, 2016 at 03:23:19PM +0300, Michael S. Tsirkin wrote: > If platform_driver_register fails, we should > cleanup fw_cfg_top_ko before exiting. > > Signed-off-by: Michael S. Tsirkin Acked-by: Gabriel Somlo Thanks, --Gabriel > --- > drivers/firmware/qemu_fw_cfg.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c > index fedbff5..e4c4714 100644 > --- a/drivers/firmware/qemu_fw_cfg.c > +++ b/drivers/firmware/qemu_fw_cfg.c > @@ -727,12 +727,18 @@ device_param_cb(mmio, &fw_cfg_cmdline_param_ops, NULL, S_IRUSR); > > static int __init fw_cfg_sysfs_init(void) > { > + int ret; > + > /* create /sys/firmware/qemu_fw_cfg/ top level directory */ > fw_cfg_top_ko = kobject_create_and_add("qemu_fw_cfg", firmware_kobj); > if (!fw_cfg_top_ko) > return -ENOMEM; > > - return platform_driver_register(&fw_cfg_sysfs_driver); > + ret = platform_driver_register(&fw_cfg_sysfs_driver); > + if (ret) > + fw_cfg_kobj_cleanup(fw_cfg_top_ko); > + > + return ret; > } > > static void __exit fw_cfg_sysfs_exit(void) > -- > MST