From patchwork Fri Jan 11 16:17:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10760279 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 5D52313B4 for ; Fri, 11 Jan 2019 16:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CEED29FF0 for ; Fri, 11 Jan 2019 16:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4131329FEA; Fri, 11 Jan 2019 16:17:16 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDFB029FF0 for ; Fri, 11 Jan 2019 16:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387835AbfAKQRJ (ORCPT ); Fri, 11 Jan 2019 11:17:09 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:60312 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbfAKQRJ (ORCPT ); Fri, 11 Jan 2019 11:17:09 -0500 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7778C53E; Fri, 11 Jan 2019 17:17:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547223427; bh=3pJga9R1B/FIA8pcX8vkk2nYCtc3WjgRr7I+PJZ0rO8=; h=From:To:Cc:Subject:Date:From; b=rxgVx/HV8b+G1nXzPkV3z7qj7pJTFNtnldgOl9xhPHYuNK82tGeW/6ZgtGwiEsxhK 3M78pxTAbfQY+cqrylJ/xy82VpHwF9yPu8vJ6OdEeFKs1zAsoSQQlGqM51e2vxORUh OedHzGuGyM1Xr+99tt2OvTUDYZhvJ635KOcN+FyA= From: Kieran Bingham To: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Kieran Bingham Cc: Steve Longerbeam Subject: [PATCH v2] media: i2c: adv748x: Use devm to allocate the device struct Date: Fri, 11 Jan 2019 16:17:03 +0000 Message-Id: <20190111161703.7972-1-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.17.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Longerbeam Switch to devm_kzalloc() when allocating the adv748x device struct. The sizeof() is updated to determine the correct allocation size from the dereferenced pointer type rather than hardcoding the struct type. Signed-off-by: Steve Longerbeam Reviewed-by: Kieran Bingham [Kieran: Change sizeof() to dereference the pointer type] Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- drivers/media/i2c/adv748x/adv748x-core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c index 060d0c5b4989..1e5c7bbcf6b2 100644 --- a/drivers/media/i2c/adv748x/adv748x-core.c +++ b/drivers/media/i2c/adv748x/adv748x-core.c @@ -674,7 +674,7 @@ static int adv748x_probe(struct i2c_client *client, if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; - state = kzalloc(sizeof(struct adv748x_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (!state) return -ENOMEM; @@ -772,7 +772,6 @@ static int adv748x_probe(struct i2c_client *client, adv748x_dt_cleanup(state); err_free_mutex: mutex_destroy(&state->mutex); - kfree(state); return ret; } @@ -791,8 +790,6 @@ static int adv748x_remove(struct i2c_client *client) adv748x_dt_cleanup(state); mutex_destroy(&state->mutex); - kfree(state); - return 0; }