All of lore.kernel.org
 help / color / mirror / Atom feed
From: JAILLET Christophe <jaillet.christophe@wanadoo.fr>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] drivers/media/video/videobuf-dma-sg.c: avoid to clear memory twice
Date: Mon, 09 Jun 2008 00:08:00 +0200	[thread overview]
Message-ID: <g2hl81$btp$1@ger.gmane.org> (raw)

From: Christophe Jaillet <jaillet.christophe@wanadoo.fr>

Hi, here is a patch against linux/drivers/usb/atm/cxacru.c which :

1) Remove a useless initialisation of 'i'
2) Avoid to clear the memory allocated twice (once in 'kcalloc', once in 
'sg_init_table')
3) Remove a test that can never trigger. The function returns NULL in 
such a case, so we know that at this point 'pages[0]' != NULL


Signed-off-by: Christophe Jaillet <jaillet.christophe@wanadoo.fr>

---

diff --git a/drivers/media/video/videobuf-dma-sg.c
b/drivers/media/video/videobuf-dma-sg.c
index 03a7b94..8ed6082 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -80,17 +80,15 @@ struct scatterlist*
  videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset)
  {
         struct scatterlist *sglist;
-       int i = 0;
+       int i;

         if (NULL == pages[0])
                 return NULL;
-       sglist = kcalloc(nr_pages, sizeof(*sglist), GFP_KERNEL);
+       sglist = kmalloc(nr_pages * sizeof(*sglist), GFP_KERNEL);
         if (NULL == sglist)
                 return NULL;
         sg_init_table(sglist, nr_pages);

-       if (NULL == pages[0])
-               goto nopage;
         if (PageHighMem(pages[0]))
                 /* DMA to highmem pages might not work */
                 goto highmem;


                 reply	other threads:[~2008-06-08 22:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='g2hl81$btp$1@ger.gmane.org' \
    --to=jaillet.christophe@wanadoo.fr \
    --cc=linux-kernel@vger.kernel.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.