From patchwork Fri Apr 12 10:19:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 10897903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 747A11669 for ; Fri, 12 Apr 2019 10:20:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5297428E62 for ; Fri, 12 Apr 2019 10:20:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4690D2880D; Fri, 12 Apr 2019 10:20:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CD93928E42 for ; Fri, 12 Apr 2019 10:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nmRuxbcmkniRFOLfcz9kicgYugX4VYoPwaulNSFEkyo=; b=cyxZ1vuZqJcTsu 1L8BszQ5OkyXH15BQYm+NagnmMlX+a5Ew2yy/6bXO0tyUelt6OqHpoA3ij7slwLMlkI802i1gM6nO yWXpNDKb78UM5q+KW0fuWqA2ENxX8pYdg6he98c4chV3UDHvI5bpOPebnfGRGOkygZgroLYMBKP+Z TCYYw0LRnKXQYbwZmop7GatVVC0oRKQxgG2sOYVblvZtRlYPKp8GT2kF2NRG2DzyEC8Vka2sVl7TT cGW8+fL38+H+AlTQIbQdYq7p9QmkDC3ArZQByqUHl+t/NTbGEmnFb1tFE/FmTCM1+2KYF6COEfkkT F35Bt/hfORGLFtPW+nMQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEtIP-0005rr-GF; Fri, 12 Apr 2019 10:20:33 +0000 Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEtHk-0003g2-Jb for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2019 10:19:56 +0000 X-IronPort-AV: E=Sophos;i="5.60,340,1549954800"; d="scan'208";a="29792645" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Apr 2019 03:19:52 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.108) with Microsoft SMTP Server (TLS) id 14.3.352.0; Fri, 12 Apr 2019 03:19:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gdezC86ZmpzMyWPpEH1Cs31OEIomGxRPFZpAXTnUe1s=; b=ZFJS3PHUksiC1V6+CJ5ZXhoDCUF15nL9+Eo6Ti8eu2uW4szRWj9dm1UFDutmHedWN+pvBzICGhQziR9F4YxTy/4sr7WGqZ7nbzaalszPXViDXaqKUGLlCXHWsmnfYrM0Kaeo2YqauirL1nmkOV63FHcoYqAfKZE1Ut9BZTBWMhI= Received: from DM5PR11MB1242.namprd11.prod.outlook.com (10.168.108.8) by DM5PR11MB1947.namprd11.prod.outlook.com (10.175.88.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.16; Fri, 12 Apr 2019 10:19:50 +0000 Received: from DM5PR11MB1242.namprd11.prod.outlook.com ([fe80::e0e3:1d51:9e3e:6dc]) by DM5PR11MB1242.namprd11.prod.outlook.com ([fe80::e0e3:1d51:9e3e:6dc%3]) with mapi id 15.20.1792.016; Fri, 12 Apr 2019 10:19:50 +0000 From: To: , , , Subject: [PATCH 3/3] media: atmel: atmel-isc: fix asd memory allocation Thread-Topic: [PATCH 3/3] media: atmel: atmel-isc: fix asd memory allocation Thread-Index: AQHU8RlCk4yC9UUXy0av/TaU4uWanQ== Date: Fri, 12 Apr 2019 10:19:49 +0000 Message-ID: <1555064098-19310-4-git-send-email-eugen.hristev@microchip.com> References: <1555064098-19310-1-git-send-email-eugen.hristev@microchip.com> In-Reply-To: <1555064098-19310-1-git-send-email-eugen.hristev@microchip.com> Accept-Language: ro-RO, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR06CA0111.eurprd06.prod.outlook.com (2603:10a6:803:8c::40) To DM5PR11MB1242.namprd11.prod.outlook.com (2603:10b6:3:14::8) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Eugen.Hristev@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e657cb9f-1ef6-4a87-7acb-08d6bf306517 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328)(7193020); SRVR:DM5PR11MB1947; x-ms-traffictypediagnostic: DM5PR11MB1947: x-microsoft-antispam-prvs: x-forefront-prvs: 0005B05917 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(39860400002)(136003)(376002)(199004)(189003)(105586002)(54906003)(102836004)(36756003)(50226002)(26005)(14454004)(2906002)(97736004)(66066001)(6486002)(6436002)(6506007)(386003)(305945005)(7736002)(2501003)(81166006)(5660300002)(8676002)(446003)(8936002)(81156014)(107886003)(256004)(486006)(4326008)(478600001)(76176011)(110136005)(106356001)(68736007)(316002)(86362001)(3846002)(71200400001)(52116002)(72206003)(2616005)(476003)(25786009)(6116002)(186003)(6512007)(71190400001)(99286004)(11346002)(2201001)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR11MB1947; H:DM5PR11MB1242.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: sFSLpebleuBx3qxTxACDE21nSJeGDPuziWFjnc+8ktCZBfcCok8X1+UE8JcQ7iHNjY0MijhF0jIbDUZ7YIbok8mSmYbncL/JaDgQTf9gQTK27mGouA0fmurfG4QlgS8CTNDjpKBRQXb5PlGVi0tNiX+apeNMBi13+kD+rVJWwODzLpbu0ff65s29b8EztgM8KGxWUp6bvdMf+aW5j0TP7rsWfh20J2tzTy8QD529B/pYCaTBnWlhA2H9RhnXjzq8Gq94JefCDj6lVPGC5WnHL7D4TWbUyQVsHk7l14qx90FZ1hF6z9uXWKq9xGWP9UaZ24DkrMp8R9/urpD43SUUEgELG004yv1JMMqrNB1WWOFxdYqSbYbboJxGR3fxCvfFUSzYh2Rv1W/0lKqOwyeGb3Oi0xvPYRZ75sdQpqEo47M= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e657cb9f-1ef6-4a87-7acb-08d6bf306517 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2019 10:19:49.9160 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1947 X-OriginatorOrg: microchip.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190412_031953_140668_CC4AFDA7 X-CRM114-Status: GOOD ( 13.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eugen.Hristev@microchip.com, ksloat@aampglobal.com, mchehab@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eugen Hristev 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 --- drivers/media/platform/atmel/atmel-isc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c index aef90db..8e072a9 100644 --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -2168,8 +2168,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; @@ -2313,6 +2316,7 @@ static int atmel_isc_probe(struct platform_device *pdev) subdev_entity->asd); if (ret) { fwnode_handle_put(subdev_entity->asd->match.fwnode); + kfree(subdev_entity->asd); goto cleanup_subdev; }