WIP: handle error values from filp_open() sandbox/lstelmach/logger-handle-errors
authorŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 10 Sep 2021 18:02:53 +0000 (20:02 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 10 Sep 2021 18:02:53 +0000 (20:02 +0200)
Change-Id: I5a694555bcd082506330e08f48ed4b7043c4e120

kernel/logger.c

index 48dbf4aab9e5e55ffa5122c83269f4fafc8424d8..811e7452d33ecc253ecc82d036c024ecd6b2ead6 100644 (file)
@@ -484,10 +484,13 @@ static struct file *make_new_file(struct file *file)
 
        nfile = filp_open(p, O_WRONLY, 0);
        kfree(pbuf);
-       if (!nfile) {
+       if (IS_ERR_OR_NULL(nfile)) {
+               pr_err("filp_open(%s): %ld\n", pbuf, PTR_ERR(nfile));
+               kfree(pbuf);
                return ERR_PTR(-EFAULT);
        }
 
+       kfree(pbuf);
        nwriter = nfile->private_data;
        nwriter->prio = writer->prio;
        nwriter->tag = kstrdup(writer->tag, GFP_KERNEL);