From patchwork Mon Dec 2 10:30:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 180595 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp5012181ile; Mon, 2 Dec 2019 02:31:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxGIYR108J0TT9c/9YZJGlkFumQbs45fCVGbUxvTgiAOlVFSM70IdqZ9NVSQcERxxqVK6lr X-Received: by 2002:a17:906:1d50:: with SMTP id o16mr14944479ejh.111.1575282676855; Mon, 02 Dec 2019 02:31:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575282676; cv=none; d=google.com; s=arc-20160816; b=0eXjcXm+IMkCyKhwIEdJR2HJGXxHo9lyOrb3RUYVKbCgxNgnq3CFnRAvpFKseGUKj1 ly7gcc0usQ9DMBB/lZl2CW6tzksp8i5kEhVIGUUCZhk49SgW+yOFZcmXjQQA7g0C8Q2j 2af4+Aq3t7QS33j4B7D8T5tczRZLgE9cesHvf9U/Q19rVqV5zulteuklxd5srwbi6Hsf UtCNzg3In/Hf9N+qocoY5JUpRKpxS4/o8qm0q/hwoyD2V9KSihAcEbAYT5MeqRXq2J0Y GWua8Tg84DeCnIWR+9eTUMNy/AF/4k6B4wTCU6yRloVv6zegxf54YMBV3AqjkFjAPygB cqsQ== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eFBFGv//5UKtfgO4bFKkyNYQ6cGLJVbXdL6jceejJm8=; b=rplXNYV+j31jrJgLritL4wAJYg9xL0excrFDmYCvq9gF0oLqvA/5FTbe5qW5s7TV2R TykvBAdjWvClasXQSPqCrP2koUOAz48i97myJLGsZYCwcA8hwn4cBcxthtvsvxRvCA5U BbCImT7hPwoDfIEf5OifuJW1swGILZi0mUZwAGit3HQM2udK2xhMmjBxkHn1/mETX+a1 1BO3J00jjQ6VfSufRSY1uyC7pceC/cKDTDEoFujTlr1toZcBE38VfbxXwDftGTcxaoJf za0v55y6XVodtw9QnqSSJRL1CylOrozcN3W2r1Dy0d7mF7zZM8jvG19OghPF4xpSZuM0 yQdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lW8yAxXH; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21si4015152edq.191.2019.12.02.02.31.16; Mon, 02 Dec 2019 02:31:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=lW8yAxXH; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbfLBKbQ (ORCPT + 15 others); Mon, 2 Dec 2019 05:31:16 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52481 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727366AbfLBKbQ (ORCPT ); Mon, 2 Dec 2019 05:31:16 -0500 Received: by mail-wm1-f67.google.com with SMTP id p9so6157311wmc.2 for ; Mon, 02 Dec 2019 02:31:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=eFBFGv//5UKtfgO4bFKkyNYQ6cGLJVbXdL6jceejJm8=; b=lW8yAxXH4zi4M/hvk9KeDdBoZMCYUOMLZIdhW7BvUuXAttcVTc/RPkPZIZe76elInO gbcnrMAO5EgV0B+TkTcUnHeTGbonQ1auQYWunEKlX/dqnEmG+kXKzpiWQ4eNchncjTKU scvpe4avMcGDklJzTNcAsnEXL3hpkHrOAzmiD43rwfzLcpopCjwWpjMCXvKn/p9aR0Xr 7EkiBie9VrunVBM382X5iIQrnXseCDkKTu5BffhCI0o4xib5XHQn4+PPSo63D4iq1yBV oJSRL9YRruSv6CJV4/XDodnufkAxmt1QCALMKuMGI4wPS7dl/5chm5tYQaQm/JAGjSHT irEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eFBFGv//5UKtfgO4bFKkyNYQ6cGLJVbXdL6jceejJm8=; b=UrzSieaQypd/i5+XJn8yt5urLjzhQfJCDBiuft0sUDuRfBnczTT3Emda5nhl5mqrn5 YUKeIhRXY5cttas2VdKA6dfhgi5eAh3QiNVDiu1tLmgv0CZiEf3YtoeZsGh8a8es72pf VOOhODY5s+tGlQFUxgUrQHrn9QzLNMw0zGhX+Ay1jXbu9I/bMktjxglqlaIHOt0QePAK oWMina0p3+Ut4qqJp3HLUTVU5UkT52yATPcq85O9yOVbGHqH/I5KF2qjFRwfMgbyiMKK DgcWf0LiW6RzamFV9gqGGewAei1Lx2VCBz6rpasY1++wjuO9xFvqODo1B18i1P43xUzg RZYg== X-Gm-Message-State: APjAAAVkQUgIPagJJQqAnBpX+u0O4x2xpa5cGt2pGmRaoQbCMEV5K3MK whHgjg7HkhuJF30SsUQLdzzETSFOcZ4= X-Received: by 2002:a1c:5451:: with SMTP id p17mr17281456wmi.57.1575282673781; Mon, 02 Dec 2019 02:31:13 -0800 (PST) Received: from localhost.localdomain ([2.27.35.155]) by smtp.gmail.com with ESMTPSA id r6sm26402860wrq.92.2019.12.02.02.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 02:31:13 -0800 (PST) From: Lee Jones To: stable@vger.kernel.org Subject: [PATCH 4.19 08/15] media: atmel: atmel-isc: fix asd memory allocation Date: Mon, 2 Dec 2019 10:30:43 +0000 Message-Id: <20191202103050.2668-8-lee.jones@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202103050.2668-1-lee.jones@linaro.org> References: <20191202103050.2668-1-lee.jones@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eugen Hristev [ Upstream commit 1e4e25c4959c10728fbfcc6a286f9503d32dfe02 ] 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 --- drivers/media/platform/atmel/atmel-isc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.24.0 diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c index d89e14524d42..f2b09ea107b1 100644 --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -2062,8 +2062,11 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) 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) { of_node_put(rem); ret = -ENOMEM; @@ -2209,6 +2212,7 @@ static int atmel_isc_probe(struct platform_device *pdev) &subdev_entity->notifier); if (ret) { dev_err(dev, "fail to register async notifier\n"); + kfree(subdev_entity->asd); goto cleanup_subdev; }