Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4292174yba; Wed, 17 Apr 2019 08:30:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLVpz9Sbo/4d5AmMAigbsV8qmxxgpPWUrvPlQ7oZiJh047vWsZBbI5j754L3CgzAgM+SnD X-Received: by 2002:a65:5183:: with SMTP id h3mr83391828pgq.53.1555515054565; Wed, 17 Apr 2019 08:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555515054; cv=none; d=google.com; s=arc-20160816; b=B3S6HI8Ko5QzOUAU2fuNbbP+wplIVVQcitR4NrdyEF0adrgGe2sOF4cFrwWia3L2Pt Jz9ozL5Nl/nlEPTue7C5645Jxx1tjVNqWOU0pbW83mIFDD8CRzznsky2SuC/c93BYYGt WYdU52JoMm7o41mX5aa2HzCySlI030qfE5zwNNGWBM7HjO0NPCaIYUynGAMfBOHRRU4I 2y9PuoHjUk2W/eHAurOjyJQi9gqzgjQ5q0uyiSnIzATazFZsTAK1QT/HvZGv+k37UqM/ Ow+uQE3y8nPvTjRdTbQcq5AAMJAzbZrfVC9y3fXfN1REjMU5DYIkMK93ro4GLP+ZaWty UHuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=NCWS3yc7MwovTkphH9ApLdhcE57NsDmtG6xOaqw9beM=; b=YuFGSsNeQMuTdnKXHwgUstQBXgxBohHs9+I7xNR/SLzBqp8LC70BJCQNJRx5W7N1hb cE6zlWnI/ZTTuhU1DKoqHfUk4cfeOlbxk4WER61978DzOkyu42ygMtBD25TAZllKJNsN v16dlTuevS+95bfoueSOiL94MEmaiz1QAkxu42sCL3VYQmOYWgVsxRyAyIWpXG9vLEhn +d0vu86rkSvVVBcbHFt6dBVTyaO02EMKoZaaOPB6VwSXn+/t7XKfKk770hlE4OG3RtZS BNGSg8/e7DI4CaGSnQxu46y6PWSTG+J13sNINjwt+azPbhtz9CJ7MVyqMeZC3z58T8Dl +SfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=SfyP+U5G; 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=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si36310556pgs.215.2019.04.17.08.30.39; Wed, 17 Apr 2019 08:30:54 -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=pass header.i=@163.com header.s=s110527 header.b=SfyP+U5G; 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=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732749AbfDQP1z (ORCPT + 99 others); Wed, 17 Apr 2019 11:27:55 -0400 Received: from m50-138.163.com ([123.125.50.138]:52110 "EHLO m50-138.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732719AbfDQP1y (ORCPT ); Wed, 17 Apr 2019 11:27:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=NCWS3yc7MwovTkphH9 ApLdhcE57NsDmtG6xOaqw9beM=; b=SfyP+U5G9o/hhPYHzdA3Kah4u5JVJ+yfaw shcWahP/A1tBd2Op2zj/NUbq8RJzit9qMWgd+tfvdjsRs4m3NTlHZWyjSScxt6/6 axL1Sr5oFjTZgRb4MBhuz30g7XiONkoeUJVggrU7dWch5hifWdo+6P19pyXbdLe+ FjQf51ZQk= Received: from bp.localdomain (unknown [218.106.182.174]) by smtp1 (Coremail) with SMTP id C9GowAD3_GjbRbdcgacyAw--.603S3; Wed, 17 Apr 2019 23:27:27 +0800 (CST) From: Pan Bian To: Benjamin Herrenschmidt , Joel Stanley Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: fsi: use put_device to release resource on error path Date: Wed, 17 Apr 2019 23:27:11 +0800 Message-Id: <1555514831-124442-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: C9GowAD3_GjbRbdcgacyAw--.603S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF18uF1rJr45tr43Wr45Wrg_yoWfCrgEka 1Uurn7Xr4UWa4DA3WYvFWrZrZ29as8WF1rGF1kta4rGryIvr13Zw17Xr4kAa1UWrs7JFWq qrWqgr4fA3s8WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUULFx5UUUUU== X-Originating-IP: [218.106.182.174] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBUR+ZclaD2H1MKgAAsz Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the function fsi_slave_init, kfree is used to release slave if error occurs during set smode. Some fields of slave will not be released. Resulting in memory leak. Instread, put_device should be used to correctly release resources. Fixes: d1dcd6782576("fsi: Add cfam char devices") Signed-off-by: Pan Bian --- drivers/fsi/fsi-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 2c31563..2bb6625 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1056,8 +1056,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) dev_warn(&master->dev, "can't set smode on slave:%02x:%02x %d\n", link, id, rc); - kfree(slave); - return -ENODEV; + goto err_free; } if (master->link_config) master->link_config(master, link, -- 2.7.4