From: Leon Romanovsky <leon@kernel.org>
To: "Marciniszyn,
Mike" <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: SF Markus Elfring
<elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"Hefty,
Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Julia Lawall <julia.lawall-L2FTfq7BK8M@public.gmane.org>
Subject: Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation
Date: Fri, 19 Aug 2016 15:41:06 +0000 [thread overview]
Message-ID: <20160819154106.GC18515@leon.nu> (raw)
In-Reply-To: <32E1700B9017364D9B60AED9960492BC2D0AF815-RjuIdWtd+YbTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: "Marciniszyn,
Mike" <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: SF Markus Elfring
<elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"Hefty,
Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Julia Lawall <julia.lawall-L2FTfq7BK8M@public.gmane.org>
Subject: Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation
Date: Fri, 19 Aug 2016 18:41:06 +0300 [thread overview]
Message-ID: <20160819154106.GC18515@leon.nu> (raw)
In-Reply-To: <32E1700B9017364D9B60AED9960492BC2D0AF815-RjuIdWtd+YbTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Leon Romanovsky <leon@kernel.org>
To: "Marciniszyn, Mike" <mike.marciniszyn@intel.com>
Cc: SF Markus Elfring <elfring@users.sourceforge.net>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Doug Ledford <dledford@redhat.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
"Hefty, Sean" <sean.hefty@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation
Date: Fri, 19 Aug 2016 18:41:06 +0300 [thread overview]
Message-ID: <20160819154106.GC18515@leon.nu> (raw)
In-Reply-To: <32E1700B9017364D9B60AED9960492BC2D0AF815@fmsmsx120.amr.corp.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-08-19 15:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 7:06 [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-19 7:06 ` SF Markus Elfring
[not found] ` <620b3961-6e05-6638-4ca8-18766acc91f4-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2016-08-19 15:27 ` Marciniszyn, Mike
2016-08-19 15:27 ` Marciniszyn, Mike
2016-08-19 15:27 ` Marciniszyn, Mike
[not found] ` <32E1700B9017364D9B60AED9960492BC2D0AF815-RjuIdWtd+YbTXloPLtfHfbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2016-08-19 15:41 ` Leon Romanovsky [this message]
2016-08-19 15:41 ` Leon Romanovsky
2016-08-19 15:41 ` Leon Romanovsky
[not found] ` <20160819154106.GC18515-2ukJVAZIZ/Y@public.gmane.org>
2016-08-19 15:42 ` Marciniszyn, Mike
2016-08-19 15:42 ` Marciniszyn, Mike
2016-08-19 15:42 ` Marciniszyn, Mike
2016-08-19 15:45 ` Leon Romanovsky
2016-08-19 15:45 ` Leon Romanovsky
2016-08-23 16:43 ` Doug Ledford
2016-08-23 16:43 ` Doug Ledford
2016-08-19 15:37 ` Leon Romanovsky
2016-08-19 15:37 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160819154106.GC18515@leon.nu \
--to=leon@kernel.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=julia.lawall-L2FTfq7BK8M@public.gmane.org \
--cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.