lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160819154106.GC18515@leon.nu>
Date:   Fri, 19 Aug 2016 18:41:06 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     "Marciniszyn, Mike" <mike.marciniszyn@...el.com>
Cc:     SF Markus Elfring <elfring@...rs.sourceforge.net>,
        "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
        Doug Ledford <dledford@...hat.com>,
        Hal Rosenstock <hal.rosenstock@...il.com>,
        "Hefty, Sean" <sean.hefty@...el.com>,
        LKML <linux-kernel@...r.kernel.org>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
        Julia Lawall <julia.lawall@...6.fr>
Subject: Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its
 implementation

On Fri, Aug 19, 2016 at 03:27:20PM +0000, Marciniszyn, Mike wrote:
> > Subject: [PATCH] IB/qib: Use memdup_user() rather than duplicating its
> > diff --git a/drivers/infiniband/hw/qib/qib_fs.c
> 
> I would be even more aggressive at reducing lines of code.
> 
> For example do direct returns when ok to do:
>         if (pos != 0 || count != sizeof(struct qib_flash))
>                 return -EINVAL;
> 
>         tmp = memdup_user(buf, count);
>         if (IS_ERR(tmp))
>                 return PTR_ERR(tmp);
> 
> The bail_tmp: label is then not needed.

You still need to free tmp allocation if qib_eeprom_write failed and
this is your bail_tmp.

341         tmp = kmalloc(count, GFP_KERNEL);
342         if (!tmp) {
343                 ret = -ENOMEM;
344                 goto bail;
345         }
346
347         if (copy_from_user(tmp, buf, count)) {
348                 ret = -EFAULT;
349                 goto bail_tmp;
350         }
351
352         dd = private2dd(file);
353         if (qib_eeprom_write(dd, pos, tmp, count)) {
354                 ret = -ENXIO;
355                 qib_dev_err(dd, "failed to write to flash\n");
356                 goto bail_tmp;
357         }

> 
> Mike
> 

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ