From patchwork Fri Jun 14 09:47:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 166804 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1828473ilk; Fri, 14 Jun 2019 02:48:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqymCGXwKXgrK1u1cYNgYWPn3K9xM90UoQxF5oYdE+E7lEqaJ7yZkzbrNXm71++zIRpW6+Pm X-Received: by 2002:aa7:90d3:: with SMTP id k19mr95159096pfk.1.1560505708074; Fri, 14 Jun 2019 02:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560505708; cv=none; d=google.com; s=arc-20160816; b=G+dQEOLJq8ZakDWilz4zYrOoiNLzmyfILweGaOBg6R1nfJkb2BV0l0ewD8DujBk9Z7 Gu+w+ncTJVtY9vV9XmvWAuvfYlRSrRxttGtXAZOl79A8C5+/4LGmpy/mtbIFeBljIXsA L8nLz9kHmIU1Wkz6Zp1TLuhNt4vY4IuJOyl0VMxIXZdv2CRaClsMW0y7Wx3E/CirvTP7 yvN0A0YhDgaBmH+YxQqtSi/gMP96zsWZlO6IBxIGqJIohA18W+6+WYarOvWE+EvUejV/ HbUOusMig+yxH2ylWhi0iUUuT/sDJ+HhpGMvzu+LSqQgiCSLKsX6dJ4jXxeYrPr7w8zJ 4pqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=CeA/M2wbhSX9/oRhSlItQf5j9sDR2vZKaPvqDzBoPkU=; b=Bgy2Y4tKzkdXTRw0/cmI0VivlJgwdfgA3ARbrnpiQdT34zvLPtMncCsNyEsxftXFFV 4TRcTZZIT7cCd4AdB3Ik93pfXAkieoQXU/o8CDJVE2Pj+jXiUMHYbxzg85q5NUeOQKu5 8MNrjTuuRvMu2y6h2mhcOV+VM8Nv4aybDbuu9V0/MD4fgc56rIsLz0v1a1kX7qJHJrGV yoVUn92U7k9wPZ6pyXARhOQgKwMoLGBX1lrhk/qf40+FKWSoQ5vkMZBtA0O4rvkvvxCN w29Q7Uq1GAfSHYezQ0CdiBDZ7MrrUmDZQsUnRXSfsXhC7PwyUTgdBdt+82hHM7pfs3o+ s2vQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i11si1939770pfa.240.2019.06.14.02.48.27; Fri, 14 Jun 2019 02:48:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727263AbfFNJs0 (ORCPT + 15 others); Fri, 14 Jun 2019 05:48:26 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:34378 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726900AbfFNJs0 (ORCPT ); Fri, 14 Jun 2019 05:48:26 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B4271B86F5AD6BE50AD7; Fri, 14 Jun 2019 17:48:23 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.439.0; Fri, 14 Jun 2019 17:48:13 +0800 From: John Garry To: CC: , , , , John Garry Subject: [PATCH] bus: hisi_lpc: Don't use devm_kzalloc() to allocate logical PIO range Date: Fri, 14 Jun 2019 17:47:04 +0800 Message-ID: <1560505624-39955-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If, after registering a logical PIO range, the driver probe later fails, the logical PIO range memory will be released automatically. This causes an issue, in that the logical PIO range is not unregistered (that is not supported) and the released range memory may be later referenced Allocate the logical PIO range with kzalloc() to avoid this potential issue. Fixes: adf38bb0b5956 ("HISI LPC: Support the LPC host on Hip06/Hip07 with DT bindings") Signed-off-by: John Garry -- 2.17.1 diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c index 19d7b6ff2f17..d9ab4e76010d 100644 --- a/drivers/bus/hisi_lpc.c +++ b/drivers/bus/hisi_lpc.c @@ -599,7 +599,7 @@ static int hisi_lpc_probe(struct platform_device *pdev) if (IS_ERR(lpcdev->membase)) return PTR_ERR(lpcdev->membase); - range = devm_kzalloc(dev, sizeof(*range), GFP_KERNEL); + range = kzalloc(sizeof(*range), GFP_KERNEL); if (!range) return -ENOMEM; @@ -610,6 +610,7 @@ static int hisi_lpc_probe(struct platform_device *pdev) ret = logic_pio_register_range(range); if (ret) { dev_err(dev, "register IO range failed (%d)!\n", ret); + kfree(range); return ret; } lpcdev->io_host = range;