Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751563AbdIJME6 (ORCPT ); Sun, 10 Sep 2017 08:04:58 -0400 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:31704 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483AbdIJME5 (ORCPT ); Sun, 10 Sep 2017 08:04:57 -0400 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 10 Sep 2017 14:04:55 +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-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] media: v4l2-pci-skeleton: Fix error handling path in 'skeleton_probe()' Date: Sun, 10 Sep 2017 13:53:22 +0200 Message-Id: <20170910115322.15482-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 860 Lines: 27 If this memory allocation fails, we must release some resources, as already done in the code below and above. Signed-off-by: Christophe JAILLET --- 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, -- 2.11.0