Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp554687pxb; Wed, 3 Mar 2021 09:26:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3b4wJfuP3sZ5NCvQckWi83RbpPOlemUPHmoFSMjnNe0uaBZeNmN+p3qEQ7EKnoXmcI31B X-Received: by 2002:a17:906:ca1:: with SMTP id k1mr27176732ejh.223.1614792405774; Wed, 03 Mar 2021 09:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614792405; cv=none; d=google.com; s=arc-20160816; b=iQ4vXv9h80EVmyYQ93diyZVmT6zhFRtJoSz0sDgH4RNejY4w3j/ARuSVrXCwx4uy7m psqeG7xOQ23cyWOWOqiYRxQ+BFX6FLzlnP0/Ok9F5IGQRsx1Bzjk/rJFm3tYEwYSsN3A SIA6IBL2M2D0lX0uCIN5xRrEWcPXvgSgYtf5OlgNJUPQZDxq3CqLOMcjRMC82FNGcfRf rbi3m+w95LAsRjTpsp81duk8bsWFrf83WAhcUkoSSCHEkHZXcZJgtyU5SMmEc+9Vt1di RppXdbTZGcm/TmhKl+sXTPMEo8K1IkWYwa5tAe55AUsBcMjFUkNlsaZBSMMKRpkhtY6S 1+EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d6jEQgRNspja7rRKOZSrukPae/qA9XbJZ3b/ZZFZAeU=; b=W60wicwMqhj+Ci1EtIL0mUijqAouS9EEjbZW4+YppRlCiFjK/rt+L1UwBZHz8gePDB IaiDrMtJoRkg2qh1zzcgxchnjyaIPDv+tx5j+/J9S1onmdPIrZc5SNgp//VfxX1bbXaG vZZCPhPktvrKQomfG8lQ9DacxNKsLDURQjmreL+fv/JKcdEzp7W/ocHnNUN5NDDHUz+6 boHa2w6WT9TT5ysqB0trIUyJ4u1PatH+0KYUs1LOwdky1KAO3E0sZeSJz/yEVLjw9Cft HoqB69bzC6ZIMwoDKAjNBksWZMhMerdxZobl8hkgUlW8b0mO9j7S7d9v4MH7iXlWfmDr 0vNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Z/h3xkT3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si14763066eju.321.2021.03.03.09.25.40; Wed, 03 Mar 2021 09:26:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Z/h3xkT3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377478AbhCBAr1 (ORCPT + 99 others); Mon, 1 Mar 2021 19:47:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:51554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236319AbhCASoB (ORCPT ); Mon, 1 Mar 2021 13:44:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7C05D64F40; Mon, 1 Mar 2021 16:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616727; bh=1XfFHkKc5MZ1jdYHZqmhtLbMCNrVvwi3dBdETPH5AB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z/h3xkT3c9f+HKhoVlLaadm741294T6/zcGG3rX4W34r3MXAuUtujtqapH7l/16pT NcjnKjGwRVSKwCPS43UMm1s/IJ55hJ1wZz9uMf1OzjRQ/2d8PdN+QKZ9n7i5wc0nFo syeKqcyXRxu+y1YbEVR2pw8wI2kei02xeQK/QgcE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Patrik Jakobsson , Sasha Levin Subject: [PATCH 4.19 075/247] gma500: clean up error handling in init Date: Mon, 1 Mar 2021 17:11:35 +0100 Message-Id: <20210301161035.359611963@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 15ccc39b3aab667c6fa131206f01f31bfbccdf6a ] The main problem with this error handling was that it didn't clean up if i2c_add_numbered_adapter() failed. This code is pretty old, and doesn't match with today's checkpatch.pl standards so I took the opportunity to tidy it up a bit. I changed the NULL comparison, and removed the WARNING message if kzalloc() fails and updated the label names. Fixes: 1b082ccf5901 ("gma500: Add Oaktrail support") Signed-off-by: Dan Carpenter Signed-off-by: Patrik Jakobsson Link: https://patchwork.freedesktop.org/patch/msgid/X8ikkAqZfnDO2lu6@mwanda Signed-off-by: Sasha Levin --- drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c b/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c index e281070611480..fc9a34ed58bd1 100644 --- a/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c +++ b/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c @@ -279,11 +279,8 @@ int oaktrail_hdmi_i2c_init(struct pci_dev *dev) hdmi_dev = pci_get_drvdata(dev); i2c_dev = kzalloc(sizeof(struct hdmi_i2c_dev), GFP_KERNEL); - if (i2c_dev == NULL) { - DRM_ERROR("Can't allocate interface\n"); - ret = -ENOMEM; - goto exit; - } + if (!i2c_dev) + return -ENOMEM; i2c_dev->adap = &oaktrail_hdmi_i2c_adapter; i2c_dev->status = I2C_STAT_INIT; @@ -300,16 +297,23 @@ int oaktrail_hdmi_i2c_init(struct pci_dev *dev) oaktrail_hdmi_i2c_adapter.name, hdmi_dev); if (ret) { DRM_ERROR("Failed to request IRQ for I2C controller\n"); - goto err; + goto free_dev; } /* Adapter registration */ ret = i2c_add_numbered_adapter(&oaktrail_hdmi_i2c_adapter); - return ret; + if (ret) { + DRM_ERROR("Failed to add I2C adapter\n"); + goto free_irq; + } -err: + return 0; + +free_irq: + free_irq(dev->irq, hdmi_dev); +free_dev: kfree(i2c_dev); -exit: + return ret; } -- 2.27.0