hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/platform/omap3isp/isph3a_aewb.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * isph3a.c
34 *
....@@ -9,10 +10,6 @@
910 * Contacts: David Cohen <dacohen@gmail.com>
1011 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
1112 * Sakari Ailus <sakari.ailus@iki.fi>
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License version 2 as
15
- * published by the Free Software Foundation.
1613 */
1714
1815 #include <linux/slab.h>
....@@ -291,9 +288,10 @@
291288 {
292289 struct ispstat *aewb = &isp->isp_aewb;
293290 struct omap3isp_h3a_aewb_config *aewb_cfg;
294
- struct omap3isp_h3a_aewb_config *aewb_recover_cfg;
291
+ struct omap3isp_h3a_aewb_config *aewb_recover_cfg = NULL;
292
+ int ret;
295293
296
- aewb_cfg = devm_kzalloc(isp->dev, sizeof(*aewb_cfg), GFP_KERNEL);
294
+ aewb_cfg = kzalloc(sizeof(*aewb_cfg), GFP_KERNEL);
297295 if (!aewb_cfg)
298296 return -ENOMEM;
299297
....@@ -303,12 +301,12 @@
303301 aewb->isp = isp;
304302
305303 /* Set recover state configuration */
306
- aewb_recover_cfg = devm_kzalloc(isp->dev, sizeof(*aewb_recover_cfg),
307
- GFP_KERNEL);
304
+ aewb_recover_cfg = kzalloc(sizeof(*aewb_recover_cfg), GFP_KERNEL);
308305 if (!aewb_recover_cfg) {
309306 dev_err(aewb->isp->dev,
310307 "AEWB: cannot allocate memory for recover configuration.\n");
311
- return -ENOMEM;
308
+ ret = -ENOMEM;
309
+ goto err;
312310 }
313311
314312 aewb_recover_cfg->saturation_limit = OMAP3ISP_AEWB_MAX_SATURATION_LIM;
....@@ -325,13 +323,22 @@
325323 if (h3a_aewb_validate_params(aewb, aewb_recover_cfg)) {
326324 dev_err(aewb->isp->dev,
327325 "AEWB: recover configuration is invalid.\n");
328
- return -EINVAL;
326
+ ret = -EINVAL;
327
+ goto err;
329328 }
330329
331330 aewb_recover_cfg->buf_size = h3a_aewb_get_buf_size(aewb_recover_cfg);
332331 aewb->recover_priv = aewb_recover_cfg;
333332
334
- return omap3isp_stat_init(aewb, "AEWB", &h3a_aewb_subdev_ops);
333
+ ret = omap3isp_stat_init(aewb, "AEWB", &h3a_aewb_subdev_ops);
334
+
335
+err:
336
+ if (ret) {
337
+ kfree(aewb_cfg);
338
+ kfree(aewb_recover_cfg);
339
+ }
340
+
341
+ return ret;
335342 }
336343
337344 /*