From patchwork Sun Dec 15 12:10:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 3350281 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BDE689F243 for ; Sun, 15 Dec 2013 12:10:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2129206DB for ; Sun, 15 Dec 2013 12:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4E1A206A9 for ; Sun, 15 Dec 2013 12:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754074Ab3LOMKR (ORCPT ); Sun, 15 Dec 2013 07:10:17 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:50918 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753984Ab3LOMKQ (ORCPT ); Sun, 15 Dec 2013 07:10:16 -0500 Received: by mail-pd0-f177.google.com with SMTP id q10so4216900pdj.36 for ; Sun, 15 Dec 2013 04:10:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=9p3SdtNhF6RK1DD8/dmaNL4KSjXJQxAiEtL9EFkPhus=; b=oLlHGI9OQnEaY7zxDMdw6onLMqow/Nk5jtf7gAUjoI4hzrDjhMQxur+bAtf9uA0Oed 3BAmMix2RL9V2Zsk3d9RF13H+iOs36YMIaur6OJlUC0iPDr3G8F9cSLkD+xWGci9Qk2P hVxI27AbzZTzKMsZDtxBaHU0Wk1qtRYCCxhdMzcIuVkbFZ0FTIwoyShlCtr9vK8YFCB0 joLXSonWnf1b+h8L3H/QJcuUdj7qjwxuvxUlGTOvxSwECJr7apZ8o7m+ZzaJkZ+ZROGd +ozf3WnB7tek/U/lTly8uNMzeu/ONOpzRSi/rqlIKU4M2sThcrdGU0x+SSvPdnKzsJX8 UgnA== X-Received: by 10.68.189.197 with SMTP id gk5mr14095763pbc.37.1387109416105; Sun, 15 Dec 2013 04:10:16 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-67-188-112-76.hsd1.ca.comcast.net. [67.188.112.76]) by mx.google.com with ESMTPSA id bp5sm18656971pbb.18.2013.12.15.04.10.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 15 Dec 2013 04:10:15 -0800 (PST) Date: Sun, 15 Dec 2013 04:10:11 -0800 From: Dmitry Torokhov To: Bjorn Helgaas , "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PNPACPI: check return value of pnp_add_device() Message-ID: <20131215121008.GA436@core.coreip.homeip.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 pnp_add_device() may fail so we need to handle errors and avoid leaking memory. Also, do not use ACPI-specific return codes (AE_OK) but rather standard one (0). Signed-off-by: Dmitry Torokhov --- drivers/pnp/pnpacpi/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 14655a0..4bd4c54 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -242,6 +242,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) struct pnp_dev *dev; char *pnpid; struct acpi_hardware_id *id; + int error; /* Skip devices that are already bound */ if (device->physical_node_count) @@ -300,10 +301,16 @@ static int __init pnpacpi_add_device(struct acpi_device *device) /* clear out the damaged flags */ if (!dev->active) pnp_init_resources(dev); - pnp_add_device(dev); + + error = pnp_add_device(dev); + if (error) { + put_device(&dev->dev); + return error; + } + num++; - return AE_OK; + return 0; } static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,