From patchwork Mon Sep 11 16:53:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 44022 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drRyj-0000dC-1f; Mon, 11 Sep 2017 16:54:33 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752120AbdIKQyR (ORCPT + 1 other); Mon, 11 Sep 2017 12:54:17 -0400 Received: from smtp13.smtpout.orange.fr ([80.12.242.135]:60670 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752025AbdIKQyQ (ORCPT ); Mon, 11 Sep 2017 12:54:16 -0400 Received: from localhost.localdomain ([86.196.182.67]) by mwinf5d75 with ME id 8GuB1w00k1TfVo603GuCuF; Mon, 11 Sep 2017 18:54:13 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 11 Sep 2017 18:54:13 +0200 X-ME-IP: 86.196.182.67 From: Christophe JAILLET To: mchehab@kernel.org, hans.verkuil@cisco.com, Julia.Lawall@lip6.fr Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH V2] media: v4l2-pci-skeleton: Fix error handling path in 'skeleton_probe()' Date: Mon, 11 Sep 2017 18:53:07 +0200 Message-Id: <20170911165307.17139-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.11.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If this memory allocation fails, we must release some resources, as already done in the code below and above. Signed-off-by: Christophe JAILLET --- v2: linux-media@vger.kernel.org added in cc --- samples/v4l/v4l2-pci-skeleton.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/v4l/v4l2-pci-skeleton.c b/samples/v4l/v4l2-pci-skeleton.c index 483e9bca9444..f520e3aef9c6 100644 --- a/samples/v4l/v4l2-pci-skeleton.c +++ b/samples/v4l/v4l2-pci-skeleton.c @@ -772,8 +772,10 @@ static int skeleton_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Allocate a new instance */ skel = devm_kzalloc(&pdev->dev, sizeof(struct skeleton), GFP_KERNEL); - if (!skel) - return -ENOMEM; + if (!skel) { + ret = -ENOMEM; + goto disable_pci; + } /* Allocate the interrupt */ ret = devm_request_irq(&pdev->dev, pdev->irq,