Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4534343imm; Mon, 17 Sep 2018 16:02:18 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda2VQk7BuNKwBTSWGysphtZRnCJ/T7LEXr4KvAyJESa8kTmLtVxPDNBlTFgvHDOzZDBJkZN X-Received: by 2002:a17:902:c7:: with SMTP id a65-v6mr26409057pla.264.1537225338203; Mon, 17 Sep 2018 16:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225338; cv=none; d=google.com; s=arc-20160816; b=iVnJQ0TY7qXc6zQmwrcPD1EaJisX5eCtQJQqVlvf6NY6YsO+9iMNxa0Cv8m2r2L4qd 7Lxg6FtZM119OdsR6F5UE/8+/w31WNcFAQFZgjWfl8A+clvjZyWOGS4RRTMcyln9lgfE kb3prQM3iw66RT9Q9HUW6RVjwRRaAjTiNnAlDpiKOw6ZEp1MXm+t7AJkiy+vQmIAWaoe XpQmb0vOQotGrsMuGKVpaaRz5CtaGdwxJsyKUcXhMDkK36Hacm5nxlorUFfeYveGIbHT 3fo88kbZwXBtP3FQK2jUl5nJwlR93csBFnLHE05QuUOvSrxjQSxOgjkBZEUX6QgWIYIX 58Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=5Ix2R4qghvnVqNY8F7lCiFPdRsY7Vw1SGwKLMJclJes=; b=uX32u6dqdivr1rjhbzX7N3TmAeM9ZS6aUXWrC+Kwj40pybV1CXdzHlzr7RUMmlWbJ7 wzMhF2gyI0IVgsL1+mfIF460pe1gvljDRMXIgxE8nymWa5ZHD42YiOvk0nvcUAxlfcOn SkQ7Jcb17z4J6aN4eSpKDAUmAy+T4BTPRrSZUHo5XTzKb8kS4rQN8iCUx3V7UvefDeYS GiipXQPzawa4SKWfV+yuUlRrYiQUQGlu1VVNV/fPToXRgBzhmf7jITRtse7dJgFBvYXL 4wGSvsuVfjPycp8L3w0QlRLlebswnTBdUpZW+VqrL2vWzSwbf3HlvpCHFWIPcWIVRlgP jw0g== 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 b9-v6si16011966pfi.99.2018.09.17.16.02.02; Mon, 17 Sep 2018 16:02:18 -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 S1730270AbeIREbL (ORCPT + 99 others); Tue, 18 Sep 2018 00:31:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48326 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbeIREbL (ORCPT ); Tue, 18 Sep 2018 00:31:11 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4D421C7D; Mon, 17 Sep 2018 23:01:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Vasilyev , Guenter Roeck , Sasha Levin Subject: [PATCH 4.14 040/126] firmware: vpd: Fix section enabled flag on vpd_section_destroy Date: Tue, 18 Sep 2018 00:41:28 +0200 Message-Id: <20180917211707.339231187@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anton Vasilyev [ Upstream commit 45ca3f76de0507ecf143f770570af2942f263812 ] static struct ro_vpd and rw_vpd are initialized by vpd_sections_init() in vpd_probe() based on header's ro and rw sizes. In vpd_remove() vpd_section_destroy() performs deinitialization based on enabled flag, which is set to true by vpd_sections_init(). This leads to call of vpd_section_destroy() on already destroyed section for probe-release-probe-release sequence if first probe performs ro_vpd initialization and second probe does not initialize it. The patch adds changing enabled flag on vpd_section_destroy and adds cleanup on the error path of vpd_sections_init. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev Reviewed-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/google/vpd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/firmware/google/vpd.c +++ b/drivers/firmware/google/vpd.c @@ -246,6 +246,7 @@ static int vpd_section_destroy(struct vp sysfs_remove_bin_file(vpd_kobj, &sec->bin_attr); kfree(sec->raw_name); memunmap(sec->baseaddr); + sec->enabled = false; } return 0; @@ -279,8 +280,10 @@ static int vpd_sections_init(phys_addr_t ret = vpd_section_init("rw", &rw_vpd, physaddr + sizeof(struct vpd_cbmem) + header.ro_size, header.rw_size); - if (ret) + if (ret) { + vpd_section_destroy(&ro_vpd); return ret; + } } return 0;