From patchwork Mon Apr 20 22:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11499931 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2661B6CA for ; Mon, 20 Apr 2020 22:04:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F264B2078C for ; Mon, 20 Apr 2020 22:04:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZwK+rrRi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbgDTWEa (ORCPT ); Mon, 20 Apr 2020 18:04:30 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:30774 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725774AbgDTWEa (ORCPT ); Mon, 20 Apr 2020 18:04:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587420269; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=koRDkKLTG8zaPUuuVy6B0Oldh6kvQLudDYsHC51m2RE=; b=ZwK+rrRiFIyJKCPt6I/PaLp4FGEpJDc3OMEWjzF+PlaNBTiC0s8E/KlQVWE5SUZau9aE5y JLIPalvCuy3Ehm1APK/oSiy7e6gY9USmJQ28yRUxc0lWIy9ZRMJm+Bptm8lBR4SHVXDXVY X5e2kqWlTK4FIJ7N/ZeQhG0NRsPmpjI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-szAtL_ClPXyRciQ-e8Cplg-1; Mon, 20 Apr 2020 18:04:24 -0400 X-MC-Unique: szAtL_ClPXyRciQ-e8Cplg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CABDF1853889; Mon, 20 Apr 2020 22:04:23 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-37.ams2.redhat.com [10.36.112.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC67C5C1B2; Mon, 20 Apr 2020 22:04:22 +0000 (UTC) From: Hans de Goede To: Darren Hart , Andy Shevchenko Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] platform/x86: surface3_power: i2c_acpi_new_device() returns a PTR_ERR Date: Tue, 21 Apr 2020 00:04:21 +0200 Message-Id: <20200420220421.171298-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org i2c_acpi_new_device() never returns NULL, it either returns an i2c_client or a PTR_ERR. Adjust the mshw0011_probe() error handling to take this into account. Note the goto out_err will cause i2c_unregister_device() to get called even though the i2c_acpi_new_device() fails, this is ok as it accepts a NULL pointer argument (and treats it as a no-op). Signed-off-by: Hans de Goede --- drivers/platform/x86/surface3_power.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/surface3_power.c b/drivers/platform/x86/surface3_power.c index 946ac2dc08ae..32e6e86e27dd 100644 --- a/drivers/platform/x86/surface3_power.c +++ b/drivers/platform/x86/surface3_power.c @@ -522,8 +522,10 @@ static int mshw0011_probe(struct i2c_client *client) strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE); bat0 = i2c_acpi_new_device(dev, 1, &board_info); - if (!bat0) - return -ENOMEM; + if (IS_ERR(bat0)) { + error = PTR_ERR(bat0); + goto out_err; + } data->bat0 = bat0; i2c_set_clientdata(bat0, data);