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: 53874 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ghzUe-0006eb-Cm; Fri, 11 Jan 2019 16:17:12 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387835AbfAKQRJ (ORCPT + 1 other); 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 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; }