From patchwork Sat Sep 5 22:46:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Klimov X-Patchwork-Id: 7129851 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3D1629F1CD for ; Sat, 5 Sep 2015 22:47:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A971C207A0 for ; Sat, 5 Sep 2015 22:47:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4CB520795 for ; Sat, 5 Sep 2015 22:47:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbbIEWrJ (ORCPT ); Sat, 5 Sep 2015 18:47:09 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:33961 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751848AbbIEWrI (ORCPT ); Sat, 5 Sep 2015 18:47:08 -0400 Received: by laeb10 with SMTP id b10so32663610lae.1 for ; Sat, 05 Sep 2015 15:47:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1YV+vUXA9bQHPtaP25eXr87ahVeeq47ZmwAY3nN2dKs=; b=S9csVeFRPuYa6HS/x9G/b/beVxRUdEj+Ljcpu+kosI4+AP6+TiSM8cUpMr2xSSADvG WAO/QkXCh+bRkh0h+WPuoaLCBIpd9O4Nq+e9JfEaa1h8arthXAZQD2NrjztYsHMsPkI5 tYZwo65q2gGAlsMNzPLfyLlbXNXaFR5vYtTt2Fvfl00Z+gsZ7nyQjjrLDkmekQUmQSan hTorH6jDME0EC0gS5PEfty6gY+mLwuBDWy6Of6gelSKNWiG6dp12P+iMuWL2EYsmmurl kZC49YvTvUNCiGWRkc5xhsF8YYPYK9rVedUcJk8hCc4H4HjMdstGQ4rpEyDwRRn1xFe0 CwDQ== X-Gm-Message-State: ALoCoQmOmHfNrNqHu/F3BOrxDKtUk7Xgiy/OmwnOC7LnrHLFoTE7upVG2XwHMZVNv0mbGzvLgsxD X-Received: by 10.112.144.69 with SMTP id sk5mr10317126lbb.6.1441493226348; Sat, 05 Sep 2015 15:47:06 -0700 (PDT) Received: from localhost.localdomain ([46.39.50.164]) by smtp.gmail.com with ESMTPSA id qy6sm1729828lbc.26.2015.09.05.15.47.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Sep 2015 15:47:05 -0700 (PDT) From: Alexey Klimov To: linux@roeck-us.net, linux-spi@vger.kernel.org, broonie@kernel.org Cc: linux-kernel@vger.kernel.org, djkurtz@chromium.org, klimov.linux@gmail.com, Alexey Klimov , Uwe Kleine-Koenig Subject: [PATCH RESEND 1/1] Revert "spi/doc: spi_master_put must be followed up by kfree" Date: Sun, 6 Sep 2015 01:46:54 +0300 Message-Id: <1441493214-12994-1-git-send-email-alexey.klimov@linaro.org> X-Mailer: git-send-email 2.1.4 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Guenter Roeck Actually, spi_master_put() after spi_alloc_master() must _not_ be followed by kfree(). The memory is already freed with the call to spi_master_put() through spi_master_class, which registers a release function. Calling both spi_master_put() and kfree() results in often nasty (and delayed) crashes elsewhere in the kernel, often in the networking stack. This reverts commit eb4af0f5349235df2e4a5057a72fc8962d00308a. Link to patch and concerns: https://lkml.org/lkml/2012/9/3/269 or http://lkml.iu.edu/hypermail/linux/kernel/1209.0/00790.html Alexey Klimov: This revert becomes valid after 94c69f765f1b4a658d96905ec59928e3e3e07e6a when spi-imx.c has been fixed and there is no need to call kfree() so comment for spi_alloc_master() should be fixed. Cc: Uwe Kleine-Koenig Signed-off-by: Guenter Roeck Signed-off-by: Alexey Klimov --- drivers/spi/spi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 3abb390..a5f53de 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1610,8 +1610,7 @@ static struct class spi_master_class = { * * The caller is responsible for assigning the bus number and initializing * the master's methods before calling spi_register_master(); and (after errors - * adding the device) calling spi_master_put() and kfree() to prevent a memory - * leak. + * adding the device) calling spi_master_put() to prevent a memory leak. */ struct spi_master *spi_alloc_master(struct device *dev, unsigned size) {