Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp759817ybl; Wed, 4 Dec 2019 10:23:03 -0800 (PST) X-Google-Smtp-Source: APXvYqx1ZW0oiLoKEVieEMCJ6SIwRXwa/5JSdaCNtRdGinqqH+exEE80YJ3fz6vjMOfbXhqe0BOa X-Received: by 2002:a9d:6005:: with SMTP id h5mr3784518otj.153.1575483783107; Wed, 04 Dec 2019 10:23:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575483783; cv=none; d=google.com; s=arc-20160816; b=ExhOa5ZGtecVO/JWP7KENDYKn+h32ihNdygk6QpifkSCykBcuwxm7TlvCsl97r4v5j tHLATO+Md9QxwPwMKpMgrnvpPJPcdptjQqtlArCL1/0DdbCkJJc7bcOoJP1iV/S1wDh1 vq/fhlAJ7YbCqGOhRw2haO8KHzeYltv9ENMfQfMh8Xxy+/KRVNxtA2uIQLV3r7xeRMjT ZUgkA1UoYka333Wy/vo+uQCKA3CijvjTAcLYnls9Ndwua7OpHFS+xvPIN6YL5/0dvBTN +fvdCp9OHoWguy+0PY0c/MJ0pgicW1I5cAyLqxOUYVtQTXReZfZvzsxZ/TjQea1z/bxI NiMA== 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:dkim-signature; bh=wY1nbx61txmcRL7nCZjrb2sLLR3GVPYBjJH9BtfRfto=; b=DP4Kh4Oh1c/93669T1A0q9N1dCZHm5yQQ+BnI2cGW72qEXcq0fRhDpImQI2wd0PDMj OCO8S0HLxPb/kE1k9LJuGJobAKwyNLUGdgYGbXD1ciKyHLqBepycdeWTaR49G5fu8a2G Bl1CC7PsEzfE/GHdg4MZmC2Qd7UAH4h6c6NXIR+osl3On8yMePB9QCz5kf3kmAc1sheK iV510Ntfntwsh0b/WYjl3uO+K7NBaXe/pl5763ItMxUL4oITQSqhBW3u0FpV9HxAdYJ+ HkqvUVb65NvfDoYUNzsdRe97XSlXCGRxNkVEpMKP/zBegsgL85SP9y4e2YCbjdRtxzJI UwQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jAzaupUc; 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 l7si3649091oil.77.2019.12.04.10.22.49; Wed, 04 Dec 2019 10:23:03 -0800 (PST) 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=@kernel.org header.s=default header.b=jAzaupUc; 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 S1730491AbfLDSUp (ORCPT + 99 others); Wed, 4 Dec 2019 13:20:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:58526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729950AbfLDSHu (ORCPT ); Wed, 4 Dec 2019 13:07:50 -0500 Received: from localhost (unknown [217.68.49.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBBD320674; Wed, 4 Dec 2019 18:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482869; bh=MWk4AQ2+jYOB29Ok4FHSgOcoisrRJU+A2AKBEoWaLeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jAzaupUc78orKBgsxaswk8ra6e2W4Gt+fMFiXvKKwjagJ/6XVPaC2raQd86xDsfq5 viCxT+T+7VtOe6Naj0IbRBLdMsAEqZ9m9sqBZpSYhWyjN5ijjQ16YZN1bc7eeDIqM+ 7dYq6WyQSAprQJdl+f7+mgfwjKPsnTJXZCeJYBUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugen Hristev , Hans Verkuil , Mauro Carvalho Chehab , Lee Jones Subject: [PATCH 4.14 167/209] media: atmel: atmel-isc: fix asd memory allocation Date: Wed, 4 Dec 2019 18:56:19 +0100 Message-Id: <20191204175334.976840781@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175321.609072813@linuxfoundation.org> References: <20191204175321.609072813@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Eugen Hristev commit 1e4e25c4959c10728fbfcc6a286f9503d32dfe02 upstream. The subsystem will free the asd memory on notifier cleanup, if the asd is added to the notifier. However the memory is freed using kfree. Thus, we cannot allocate the asd using devm_* This can lead to crashes and problems. To test this issue, just return an error at probe, but cleanup the notifier beforehand. Fixes: 106267444f ("[media] atmel-isc: add the Image Sensor Controller code") Signed-off-by: Eugen Hristev Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/atmel/atmel-isc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -1722,8 +1722,11 @@ static int isc_parse_dt(struct device *d break; } - subdev_entity->asd = devm_kzalloc(dev, - sizeof(*subdev_entity->asd), GFP_KERNEL); + /* asd will be freed by the subsystem once it's added to the + * notifier list + */ + subdev_entity->asd = kzalloc(sizeof(*subdev_entity->asd), + GFP_KERNEL); if (subdev_entity->asd == NULL) { of_node_put(rem); ret = -ENOMEM; @@ -1859,6 +1862,7 @@ static int atmel_isc_probe(struct platfo &subdev_entity->notifier); if (ret) { dev_err(dev, "fail to register async notifier\n"); + kfree(subdev_entity->asd); goto cleanup_subdev; }