Message ID | 1463666915-16906-3-git-send-email-falakreyaz@gmail.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
> -----Original Message----- > From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi- > owner@vger.kernel.org] On Behalf Of Muhammad Falak R Wani > Sent: Thursday, May 19, 2016 7:09 AM > To: Hannes Reinecke > Cc: Adaptec OEM Raid Solutions; James E.J. Bottomley; Martin K. Petersen; > linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: [PATCH] [SCSI] aacraid: use kmemdup > > EXTERNAL EMAIL > > > Use kmemdup when some other buffer is immediately copied into allocated > region. It replaces call to allocation followed by memcpy, by a single > call to kmemdup. > > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> > --- > drivers/scsi/aacraid/commctrl.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c > index 4b3bb52..b381b37 100644 > --- a/drivers/scsi/aacraid/commctrl.c > +++ b/drivers/scsi/aacraid/commctrl.c > @@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, > void __user * arg) > } > } else { > struct user_sgmap* usg; > - usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) > - + sizeof(struct sgmap), GFP_KERNEL); > + usg = kmemdup(upsg, > + actual_fibsize - sizeof(struct aac_srb) > + + sizeof(struct sgmap), GFP_KERNEL); > if (!usg) { > dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB > command\n")); > rcode = -ENOMEM; > goto cleanup; > } > - memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) > - + sizeof(struct sgmap)); > actual_fibsize = actual_fibsize64; > > for (i = 0; i < usg->count; i++) { Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com> -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>> "Muhammad" == Muhammad Falak R Wani <falakreyaz@gmail.com> writes:
Muhammad> Use kmemdup when some other buffer is immediately copied into
Muhammad> allocated region. It replaces call to allocation followed by
Muhammad> memcpy, by a single call to kmemdup.
Applied to 4.8/scsi-queue.
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 4b3bb52..b381b37 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) } } else { struct user_sgmap* usg; - usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) - + sizeof(struct sgmap), GFP_KERNEL); + usg = kmemdup(upsg, + actual_fibsize - sizeof(struct aac_srb) + + sizeof(struct sgmap), GFP_KERNEL); if (!usg) { dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); rcode = -ENOMEM; goto cleanup; } - memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) - + sizeof(struct sgmap)); actual_fibsize = actual_fibsize64; for (i = 0; i < usg->count; i++) {
Use kmemdup when some other buffer is immediately copied into allocated region. It replaces call to allocation followed by memcpy, by a single call to kmemdup. Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> --- drivers/scsi/aacraid/commctrl.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)