Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4872684imm; Mon, 11 Jun 2018 21:39:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIvVQFJEKB0uyOQdCIxCJ8JdFFdo8vsTN8+BlAEnxpHc3+gnRYH8B9LEYdz2KxFV3samHuC X-Received: by 2002:a62:e506:: with SMTP id n6-v6mr2132494pff.116.1528778346540; Mon, 11 Jun 2018 21:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528778346; cv=none; d=google.com; s=arc-20160816; b=v9dxqocj1DlDpFQ+vw2rzxhbDFhRVqqoXYxPXq5R99qMNuFdezdXs7zV69bhaJMPGm 7x1HzEioZJ+ZcXkbh5iqDSSr308wmvQm2q4YN6Qb2CVFMO7r9dn8loPAHYfF+kQN1pQ0 QL8ZUKYJNI30sHWMY6oAvtBt5G73n18V1xfZKqoWumsK4Z8NlEMtaAa+nUSzLXBaMic4 3GLfJXLWMN0YaB/jSg0hcO0XL4H0cCZUs6TsPMpegGACSWbif9o6ozNRwTyYWy/sY7a8 8ds2v0WKvO7qVj6sd8djOFTTtE8vDf1HZXN+Ou3rRsie9ZU1LQ8DIz+7WkhfIKCwDsJ/ H/4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=6Oqc3O0YB3eMiwoMVJT25cP5ckOZNNh67r22qpPAUV8=; b=oa9iPXWD+7xkQ2szRWRupJmSprJ7mwaML3LVk4DQQTO7l3Rtq8+5fRhWzP/TZUVVCD XVOxEmJQBa2CKUjJM8yh7vraes6o6qeA+4Yd30NX/DlL5Ea3xeMIOAWsfDkNSkJPg1C8 X8w0GXyyvHzQv5PMxvhlsNak6nIVJgSpcBq0S+rdFdaAG+PhppVzr18otCHBuAmOPIbQ xHdb2Mbjcpi8RzzTpzmJGKCg5fOb/cHwMvmxp+CR0/362XireTLYuIC30PGD17ROD6ZE Yzi15WsSCEBSKOSaoShSjdNHnxsvjpaHtRx9NgtWFR44NkxG2vExLK3yNcYAjfaz3btd xzKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=blgNNpiT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si7083160pgn.171.2018.06.11.21.38.51; Mon, 11 Jun 2018 21:39:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=blgNNpiT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754206AbeFLEiY (ORCPT + 99 others); Tue, 12 Jun 2018 00:38:24 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37397 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754011AbeFLEiS (ORCPT ); Tue, 12 Jun 2018 00:38:18 -0400 Received: by mail-pg0-f67.google.com with SMTP id r21-v6so10498467pgv.4; Mon, 11 Jun 2018 21:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6Oqc3O0YB3eMiwoMVJT25cP5ckOZNNh67r22qpPAUV8=; b=blgNNpiTMV633FJbqXxa4HeSl7d/rsBiUwG9QRX1arYvk7xpYReN7o/Uw7m1h8ZZzI v/4ejoVKjiDiw1STlc8/trhqwGTYAhvpKVYa0awlOhAyll/rPVZ4MZYINtyxJ1Lrk+3K sOy1NWO4ROUV45VHTiZQ9tebOZqa+iLLT5Fin6Jdahur4ZJ+yUIQAi2lvDU3ag7FZNaY uOUb8TtoPTO57JA1ZV5PPTbTMTS6el8VeFvstn4MhiJyb5UkGL20JmlxMcJZS9M3h66O zg3y8Emq6f4yK87hDRInEXa8vfPr0el5zumfbyXdlqDeHaNdCGhCkGc8Q+BdLWwh87re itdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6Oqc3O0YB3eMiwoMVJT25cP5ckOZNNh67r22qpPAUV8=; b=dRxviPrQtxdaV8dmANtI7w5VJ+JrNpVH04kS+reywY2dFkE3UrYrrF7VxbGjPeLtOZ 1A6Y4Z2wgWxnB7uoDLusAe1dINa89vG4JBjqQskJeRpx8VKmBmzkY/EkCeeqpPlOY66m j/bdMhyrMKVmkgoO676kXEkDaCgdrkd/BScVhuWqZUjxADlwCOBwmp1qYdzePTgoINQO aZLckSK7bzffboGtW/BDWl3PUeDvhYEaKUR/KQgjDkcsBl+O0Q5vbi9c4PelCauTxN6p /6gyWl7kczIg9SIj40owQjkZil5jaMBFKurebXv18yAyh0LObwOv0xAtjV517lk+r2nK 7sOw== X-Gm-Message-State: APt69E1IZLR7dVUreOLYNi628hLhoGdWCEQZYiO0MY6zn2F+SzfQbBC7 vMJ+UH7Efxt95SKITIchFkOIm9HxSJQ= X-Received: by 2002:a63:a84f:: with SMTP id i15-v6mr1837192pgp.422.1528778298320; Mon, 11 Jun 2018 21:38:18 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id h12-v6sm14587783pfi.114.2018.06.11.21.38.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:38:17 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI : dock: add error handling for acpi_bus_get_device Date: Tue, 12 Jun 2018 12:38:12 +0800 Message-Id: <1528778292-41332-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When acpi_bus_get_device fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling acpi_bus_get_device. Signed-off-by: Zhouyang Jia --- drivers/acpi/dock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index e3fc1f0..02fc134 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -504,7 +504,9 @@ static ssize_t show_docked(struct device *dev, struct dock_station *dock_station = dev->platform_data; struct acpi_device *adev = NULL; - acpi_bus_get_device(dock_station->handle, &adev); + if (acpi_bus_get_device(dock_station->handle, &adev)) + return -ENODEV; + return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev)); } static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); -- 2.7.4