bug report: drm/radeon/kms: HDMI irq support

2010-05-14 Thread Dan Carpenter
Smatch complains about something from: f2594933df97 drm/radeon/kms:
HDMI irq support

drivers/gpu/drm/radeon/r600_hdmi.c +557 r600_hdmi_disable(20) error:
offset is never equal to 29696 (wrong type 0 - 255).
+
+   /* disable irq */
+   rdev-irq.hdmi[offset == R600_HDMI_BLOCK1 ? 0 : 1] = false;
   ^^
offset is 8 bits so this condition is always false.

+   radeon_irq_set(rdev);
+

regards,
dan carpenter


--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] drm_edid: There should be 6 Standard Timings

2010-05-14 Thread Dan Carpenter
Smatch complained that we initialize 6 elements in add_detailed_modes() 
but the timings[] array is declared with 5 elements.  Adam Jackson 
verified that 6 is the correct number of timings.

On Mon, May 10, 2010 at 12:08:24PM -0400, Adam Jackson wrote:
   struct std_timing timings[5];
   ^
 
 This decl is wrong, should be 6.  From the 1.4 spec:
 
 Six additional Standard Timings may be listed as a display descriptor
 (tag #FAh).
 
 The 1.3 spec is a little less explicit about it, but does show 6
 standard timing codes in the 0xFA detailed subblock, terminated by 0x0A
 in the 18th byte.  I don't have the docs for 1.2 or earlier, but we're
 paranoid enough about not adding broken timings that we should be fine.

This patch is basically a clean up, because timings[] is declared inside
a union and increasing the number of elements here doesn't change the
overall size of the union.

Signed-off-by: Dan Carpenter erro...@gmail.com
---
This patch applies to drm-next.

diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index d33c3e0..39e2cc5 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -120,7 +120,7 @@ struct detailed_non_pixel {
struct detailed_data_string str;
struct detailed_data_monitor_range range;
struct detailed_data_wpindex color;
-   struct std_timing timings[5];
+   struct std_timing timings[6];
struct cvt_timing cvt[4];
} data;
 } __attribute__((packed));

--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch -next] i915: remove unneeded null checks

2010-05-07 Thread Dan Carpenter
The encoder variable can never be null because it is used as loop
cursor in a list_for_each_entry() loop.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f6299bb..950dc8d 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -576,7 +576,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct 
drm_display_mode *mode,
struct intel_encoder *intel_encoder;
struct intel_dp_priv *dp_priv;
 
-   if (!encoder || encoder-crtc != crtc)
+   if (encoder-crtc != crtc)
continue;
 
intel_encoder = enc_to_intel_encoder(encoder);
@@ -1352,7 +1352,7 @@ intel_trans_dp_port_sel (struct drm_crtc *crtc)
struct intel_encoder *intel_encoder = NULL;
 
list_for_each_entry(encoder, mode_config-encoder_list, head) {
-   if (!encoder || encoder-crtc != crtc)
+   if (encoder-crtc != crtc)
continue;
 
intel_encoder = enc_to_intel_encoder(encoder);

--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch -next] i915/intel_sdvo: remove unneeded null check

2010-05-07 Thread Dan Carpenter
The connector variable is used as the cursor in a
list_for_each_entry() and it's always non-null so we don't need to check
it.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/i915/intel_sdvo.c 
b/drivers/gpu/drm/i915/intel_sdvo.c
index 42ceb15..179d146 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1479,7 +1479,7 @@ intel_find_analog_connector(struct drm_device *dev)
intel_encoder = enc_to_intel_encoder(encoder);
if (intel_encoder-type == INTEL_OUTPUT_ANALOG) {
list_for_each_entry(connector, 
dev-mode_config.connector_list, head) {
-   if (connector  encoder == 
intel_attached_encoder(connector))
+   if (encoder == 
intel_attached_encoder(connector))
return connector;
}
}

--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: drm_edid: potential range checking issue?

2010-05-07 Thread Dan Carpenter

Ping.  This off-by-one overflow is still there in -next.

I'm not sure how to fix it because both the declaraion and the
use in add_detailed_modes() look deliberate.

regards,
dan carpenter

On Sun, Mar 28, 2010 at 02:25:58PM +0300, Dan Carpenter wrote:
 Hi list,  :)
 
 Just going through some Smatch warnings.
 
 drivers/gpu/drm/drm_edid.c +1032 add_detailed_modes() 'data-data.timings' 5 
 = 5
   1027  /* Six modes per detailed section */
   1028  for (i = 0; i  6; i++) {
   1029  struct std_timing *std;
   1030  struct drm_display_mode *newmode;
   1031
   1032  std = data-data.timings[i];
   ^^
 
 In include/drm/drm_edid.h this array has 5 elements not 6.
 
 struct detailed_non_pixel {
 u8 pad1;
 u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
 fb=color point data, fa=standard timing data,
 f9=undefined, f8=mfg. reserved */
 u8 pad2;
 union { 
 struct detailed_data_string str;
 struct detailed_data_monitor_range range;
 struct detailed_data_wpindex color;
 struct std_timing timings[5];
 ^
 struct cvt_timing cvt[4];
 } data; 
 } __attribute__((packed));
 
 regards,
 dan carpenter

--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] i915: missing unlock on error path

2010-05-07 Thread Dan Carpenter
There was a missing mutex_unlock(dev-struct_mutex) on this error path.

Signed-off-by: Dan Carpenter erro...@gmail.com
---
I thought Jiri sent this patch earlier but a google search for stanse
struct_mutex i965_reset didn't find any patches, so I'm resending.

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 01e91ea..a605c87 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -369,6 +369,7 @@ int i965_reset(struct drm_device *dev, u8 flags)
}
} else {
DRM_ERROR(Error occurred. Don't know how to reset this 
chip.\n);
+   mutex_unlock(dev-struct_mutex);
return -ENODEV;
}
 

--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch -next] drm: dereferencing before checking for null

2010-05-07 Thread Dan Carpenter
The original code dereferences fb_helper_conn before verifying that
it's non-null.

Signed-off-by: Dan Carpenter erro...@gmail.com
---
It's never null here actually.  I could send a patch to remove the check
instead if that's prefered.

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b28e563..f5fe3a9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -96,11 +96,12 @@ static bool 
drm_fb_helper_connector_parse_command_line(struct drm_fb_helper_conn
int i;
enum drm_connector_force force = DRM_FORCE_UNSPECIFIED;
struct drm_fb_helper_cmdline_mode *cmdline_mode;
-   struct drm_connector *connector = fb_helper_conn-connector;
+   struct drm_connector *connector;
 
if (!fb_helper_conn)
return false;
 
+   connector = fb_helper_conn-connector;
cmdline_mode = fb_helper_conn-cmdline_mode;
if (!mode_option)
mode_option = fb_mode_option;

--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch -next] drm: off by one in drm_edid.c

2010-05-07 Thread Dan Carpenter
m == num_est3_modes is one past the end of the est3_modes[]. 

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 7188674..46447b0 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1383,7 +1383,7 @@ drm_est3_modes(struct drm_connector *connector, struct 
detailed_timing *timing)
for (i = 0; i  6; i++) {
for (j = 7; j  0; j--) {
m = (i * 8) + (7 - j);
-   if (m  num_est3_modes)
+   if (m = num_est3_modes)
break;
if (est[i]  (1  j)) {
mode = drm_find_dmt(connector-dev,

--

--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] nouveau: off by one in nv50_gpio_location()

2010-04-22 Thread Dan Carpenter
If gpio-line is 32 then nv50_gpio_reg[gpio-line  3] reads past the
end of the array.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/nouveau/nv50_gpio.c 
b/drivers/gpu/drm/nouveau/nv50_gpio.c
index c61782b..bb47ad7 100644
--- a/drivers/gpu/drm/nouveau/nv50_gpio.c
+++ b/drivers/gpu/drm/nouveau/nv50_gpio.c
@@ -31,7 +31,7 @@ nv50_gpio_location(struct dcb_gpio_entry *gpio, uint32_t 
*reg, uint32_t *shift)
 {
const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
 
-   if (gpio-line  32)
+   if (gpio-line = 32)
return -EINVAL;
 
*reg = nv50_gpio_reg[gpio-line  3];

--
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] nouveau: fix memory leak

2010-04-07 Thread Dan Carpenter
In the original code there was a typo and we called kfree(pgraph-ctxprog)
two times instead of kfree(pgraph-ctxvals);

Also it's OK to pass NULL variables to kfree().  checkpatch.pl complains 
about this so I removed the checks.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.c 
b/drivers/gpu/drm/nouveau/nouveau_grctx.c
index 32f0e49..06642a5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_grctx.c
+++ b/drivers/gpu/drm/nouveau/nouveau_grctx.c
@@ -134,15 +134,11 @@ nouveau_grctx_fini(struct drm_device *dev)
struct drm_nouveau_private *dev_priv = dev-dev_private;
struct nouveau_pgraph_engine *pgraph = dev_priv-engine.graph;
 
-   if (pgraph-ctxprog) {
-   kfree(pgraph-ctxprog);
-   pgraph-ctxprog = NULL;
-   }
+   kfree(pgraph-ctxprog);
+   pgraph-ctxprog = NULL;
 
-   if (pgraph-ctxvals) {
-   kfree(pgraph-ctxprog);
-   pgraph-ctxvals = NULL;
-   }
+   kfree(pgraph-ctxvals);
+   pgraph-ctxvals = NULL;
 }
 
 void

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


smatch: radeon: unsigned is never less than zero

2010-04-06 Thread Dan Carpenter
Hi list,

Smatch complains about this:

drivers/gpu/drm/radeon/radeon_display.c +563 radeon_compute_pll_legacy(115)
 warn: unsigned 'error' is never less than zero.

   561  if (pll-flags  RADEON_PLL_PREFER_CLOSEST_LOWER) {
   562  error = freq - current_freq;
   563  error = error  0 ? 0x : error;
^
error is unsigned so it's never less than zero here.

   564  } else
   565  error = abs(current_freq - freq);

regards,
dan carpenter

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] radeon: small memory leak

2010-04-06 Thread Dan Carpenter
This is an unlikely memory leak, but we may as well fix it.  It's easy
to fix and every static checker will complain if we don't.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index 247f8ee..58845e0 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -1136,6 +1136,7 @@ static int atom_execute_table_locked(struct atom_context 
*ctx, int index, uint32
int len, ws, ps, ptr;
unsigned char op;
atom_exec_context ectx;
+   int ret = 0;
 
if (!base)
return -EINVAL;
@@ -1168,7 +1169,8 @@ static int atom_execute_table_locked(struct atom_context 
*ctx, int index, uint32
if (ectx.abort) {
DRM_ERROR(atombios stuck executing %04X (len %d, WS 
%d, PS %d) @ 0x%04X\n,
base, len, ws, ps, ptr - 1);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto free;
}
 
if (op  ATOM_OP_CNT  op  0)
@@ -1183,9 +1185,10 @@ static int atom_execute_table_locked(struct atom_context 
*ctx, int index, uint32
debug_depth--;
SDEBUG(\n);
 
+free:
if (ws)
kfree(ectx.ws);
-   return 0;
+   return ret;
 }
 
 int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [patch] drm: sysfs files error handling

2010-03-30 Thread Dan Carpenter
On Sun, Mar 28, 2010 at 10:55:14PM +0200, Andi Kleen wrote:
 , Dan Carpenter wrote:

 In the original code we used j as an iterator but we used i as an
 index.

 -   for (j = 0; j  i; j++)
 -   device_remove_file(connector-kdev,
 -connector_attrs[i]);

 I guess this really should be a attribute group anyways?

 Typically when there's such a open coded loop it means the wrong
 interfaces are being used.

My graphics card is crap and doesn't use this code at all.  I'd feel 
uncomfortable those changes without being able to test it.

So while, you are probably right, someone else should probably do that.

regards,
dan carpenter

 -Andi

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] via: off by one issue

2010-03-28 Thread Dan Carpenter
fx-lock is used as the index in dev_priv-decoder_queue[fx-lock]
which is an array of VIA_NR_XVMC_LOCKS elements.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/via/via_video.c b/drivers/gpu/drm/via/via_video.c
index 6ec04ac..6efac81 100644
--- a/drivers/gpu/drm/via/via_video.c
+++ b/drivers/gpu/drm/via/via_video.c
@@ -75,7 +75,7 @@ int via_decoder_futex(struct drm_device *dev, void *data, 
struct drm_file *file_
 
DRM_DEBUG(\n);
 
-   if (fx-lock  VIA_NR_XVMC_LOCKS)
+   if (fx-lock = VIA_NR_XVMC_LOCKS)
return -EFAULT;
 
lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx-lock);

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] radeon: range check issues

2010-03-28 Thread Dan Carpenter
This change makes the array larger, MAX_SUPPORTED_TV_TIMING_V1_2 is 3
and the original size MAX_SUPPORTED_TV_TIMING is 2.

Also there were checks that were off by one.

Signed-off-by: Dan Carpenter erro...@gmail.com
---
Compile tested only.  Changing the array size seemed like the right
thing to do, in the context, but please review carefully.

diff --git a/drivers/gpu/drm/radeon/atombios.h 
b/drivers/gpu/drm/radeon/atombios.h
index 6732b5d..27e2c71 100644
--- a/drivers/gpu/drm/radeon/atombios.h
+++ b/drivers/gpu/drm/radeon/atombios.h
@@ -2912,7 +2912,7 @@ typedef struct _ATOM_ANALOG_TV_INFO_V1_2
   UCHARucTV_BootUpDefaultStandard; 
   UCHARucExt_TV_ASIC_ID;
   UCHARucExt_TV_ASIC_SlaveAddr;
-  ATOM_DTD_FORMAT  aModeTimings[MAX_SUPPORTED_TV_TIMING];
+  ATOM_DTD_FORMAT  aModeTimings[MAX_SUPPORTED_TV_TIMING_V1_2];
 }ATOM_ANALOG_TV_INFO_V1_2;
 
 typedef struct _ATOM_DPCD_INFO
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c 
b/drivers/gpu/drm/radeon/radeon_atombios.c
index 93783b1..bdc0ab3 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -1275,7 +1275,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device 
*rdev, int index,
switch (crev) {
case 1:
tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info-atom_context-bios 
+ data_offset);
-   if (index  MAX_SUPPORTED_TV_TIMING)
+   if (index = MAX_SUPPORTED_TV_TIMING)
return false;
 
mode-crtc_htotal = 
le16_to_cpu(tv_info-aModeTimings[index].usCRTC_H_Total);
@@ -1313,7 +1313,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device 
*rdev, int index,
break;
case 2:
tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 
*)(mode_info-atom_context-bios + data_offset);
-   if (index  MAX_SUPPORTED_TV_TIMING_V1_2)
+   if (index = MAX_SUPPORTED_TV_TIMING_V1_2)
return false;
 
dtd_timings = tv_info_v1_2-aModeTimings[index];


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


drm_edid: potential range checking issue?

2010-03-28 Thread Dan Carpenter
Hi list,  :)

Just going through some Smatch warnings.

drivers/gpu/drm/drm_edid.c +1032 add_detailed_modes() 'data-data.timings' 5 = 
5
  1027  /* Six modes per detailed section */
  1028  for (i = 0; i  6; i++) {
  1029  struct std_timing *std;
  1030  struct drm_display_mode *newmode;
  1031
  1032  std = data-data.timings[i];
  ^^

In include/drm/drm_edid.h this array has 5 elements not 6.

struct detailed_non_pixel {
u8 pad1;
u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
fb=color point data, fa=standard timing data,
f9=undefined, f8=mfg. reserved */
u8 pad2;
union { 
struct detailed_data_string str;
struct detailed_data_monitor_range range;
struct detailed_data_wpindex color;
struct std_timing timings[5];
^
struct cvt_timing cvt[4];
} data; 
} __attribute__((packed));

regards,
dan carpenter

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] drm: fix check for end of loop

2010-03-28 Thread Dan Carpenter
agpmem is never NULL here.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index e4865f9..7732268 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -77,7 +77,7 @@ static void *agp_remap(unsigned long offset, unsigned long 
size,
 (agpmem-bound + (agpmem-pages  PAGE_SHIFT)) =
(offset + size))
break;
-   if (!agpmem)
+   if (agpmem-head == dev-agp-memory)
return NULL;
 
/*

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] drm: sysfs files error handling

2010-03-28 Thread Dan Carpenter

In the original code we used j as an iterator but we used i as an
index.

-   for (j = 0; j  i; j++)
-   device_remove_file(connector-kdev,
-  connector_attrs[i]);

Smatch complained about that because i was potentially passed the end
of the array.  Which makes sense if we should be using j there.

I also thought that we should remove the files for connector_attrs_opt1
but to do that I had to add separate iterators for connector_attrs and
connector_attrs_opt1.

Signed-off-by: Dan Carpenter erro...@gmail.com
---
Found by static analysis and compile tested only.

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 014ce24..f144487 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -353,7 +353,10 @@ static struct bin_attribute edid_attr = {
 int drm_sysfs_connector_add(struct drm_connector *connector)
 {
struct drm_device *dev = connector-dev;
-   int ret = 0, i, j;
+   int attr_cnt = 0;
+   int opt_cnt = 0;
+   int i;
+   int ret = 0;
 
/* We shouldn't get called more than once for the same connector */
BUG_ON(device_is_registered(connector-kdev));
@@ -376,8 +379,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
 
/* Standard attributes */
 
-   for (i = 0; i  ARRAY_SIZE(connector_attrs); i++) {
-   ret = device_create_file(connector-kdev, connector_attrs[i]);
+   for (attr_cnt = 0; attr_cnt  ARRAY_SIZE(connector_attrs); attr_cnt++) {
+   ret = device_create_file(connector-kdev, 
connector_attrs[attr_cnt]);
if (ret)
goto err_out_files;
}
@@ -393,8 +396,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
case DRM_MODE_CONNECTOR_SVIDEO:
case DRM_MODE_CONNECTOR_Component:
case DRM_MODE_CONNECTOR_TV:
-   for (i = 0; i  ARRAY_SIZE(connector_attrs_opt1); i++) {
-   ret = device_create_file(connector-kdev, 
connector_attrs_opt1[i]);
+   for (opt_cnt = 0; opt_cnt  
ARRAY_SIZE(connector_attrs_opt1); opt_cnt++) {
+   ret = device_create_file(connector-kdev, 
connector_attrs_opt1[opt_cnt]);
if (ret)
goto err_out_files;
}
@@ -413,10 +416,10 @@ int drm_sysfs_connector_add(struct drm_connector 
*connector)
return 0;
 
 err_out_files:
-   if (i  0)
-   for (j = 0; j  i; j++)
-   device_remove_file(connector-kdev,
-  connector_attrs[i]);
+   for (i = 0; i  opt_cnt; i++)
+   device_remove_file(connector-kdev, connector_attrs_opt1[i]);
+   for (i = 0; i  attr_cnt; i++)
+   device_remove_file(connector-kdev, connector_attrs[i]);
device_unregister(connector-kdev);
 
 out:

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


radeon: bug using unsigned int

2010-03-11 Thread Dan Carpenter
drivers/gpu/drm/radeon/radeon_display.c +555 radeon_compute_pll_legacy(106) 
warn: unsigned 'error' is never less than zero.
   553  if (pll-flags  
RADEON_PLL_PREFER_CLOSEST_LOWER) {
   554  error = freq - 
current_freq;
   555  error = error  0 ? 
0x : error;
^

error is unsigned so it's never less than zero.

   556  } else
   557  error = 
abs(current_freq - freq);

regards,
dan carpenter

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] i915: fix small leak on error path

2010-03-06 Thread Dan Carpenter
We should free params before returning.

Signed-off-by: Dan Carpenter erro...@gmail.com

diff --git a/drivers/gpu/drm/i915/intel_overlay.c 
b/drivers/gpu/drm/i915/intel_overlay.c
index d355d1d..60595fc 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -1068,14 +1068,18 @@ int intel_overlay_put_image(struct drm_device *dev, 
void *data,
 
drmmode_obj = drm_mode_object_find(dev, put_image_rec-crtc_id,
 DRM_MODE_OBJECT_CRTC);
-   if (!drmmode_obj)
-   return -ENOENT;
+   if (!drmmode_obj) {
+   ret = -ENOENT;
+   goto out_free;
+   }
crtc = to_intel_crtc(obj_to_crtc(drmmode_obj));
 
new_bo = drm_gem_object_lookup(dev, file_priv,
put_image_rec-bo_handle);
-   if (!new_bo)
-   return -ENOENT;
+   if (!new_bo) {
+   ret = -ENOENT;
+   goto out_free;
+   }
 
mutex_lock(dev-mode_config.mutex);
mutex_lock(dev-struct_mutex);
@@ -1165,6 +1169,7 @@ out_unlock:
mutex_unlock(dev-struct_mutex);
mutex_unlock(dev-mode_config.mutex);
drm_gem_object_unreference_unlocked(new_bo);
+out_free:
kfree(params);
 
return ret;

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] fix small memory leak in ttm_memory.c

2009-11-28 Thread Dan Carpenter
I moved the allocation until after the check for (si-totalhigh == 0).

regards,
dan carpenter

Signed-off-by: Dan Carpenter erro...@gmail.com

--- orig/drivers/gpu/drm/ttm/ttm_memory.c   2009-11-28 07:05:54.0 
+0200
+++ devel/drivers/gpu/drm/ttm/ttm_memory.c  2009-11-28 07:07:52.0 
+0200
@@ -274,16 +274,17 @@ static int ttm_mem_init_kernel_zone(stru
 static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob,
 const struct sysinfo *si)
 {
-   struct ttm_mem_zone *zone = kzalloc(sizeof(*zone), GFP_KERNEL);
+   struct ttm_mem_zone *zone;
uint64_t mem;
int ret;
 
-   if (unlikely(!zone))
-   return -ENOMEM;
-
if (si-totalhigh == 0)
return 0;
 
+   zone = kzalloc(sizeof(*zone), GFP_KERNEL);
+   if (unlikely(!zone))
+   return -ENOMEM;
+
mem = si-totalram;
mem *= si-mem_unit;
 

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


[patch] move dereference after null check

2009-11-18 Thread Dan Carpenter
I moved the fence dereference after the check.  rdev is fence-rdev so I 
moved the rdev deference as well.

This was found by static analysis so I can't say whether fence is ever 
actually null but it's a good thing to do either way.

regards,
dan carpenter

Signed-off-by: Dan Carpenter erro...@gmail.com

--- orig/drivers/gpu/drm/radeon/radeon_fence.c  2009-11-16 23:48:42.0 
+0200
+++ devel/drivers/gpu/drm/radeon/radeon_fence.c 2009-11-16 23:50:23.0 
+0200
@@ -140,14 +140,15 @@
 
 bool radeon_fence_signaled(struct radeon_fence *fence)
 {
-   struct radeon_device *rdev = fence-rdev;
+   struct radeon_device *rdev;
unsigned long irq_flags;
bool signaled = false;
 
-   if (rdev-gpu_lockup) {
+   if (fence == NULL) {
return true;
}
-   if (fence == NULL) {
+   rdev = fence-rdev;
+   if (rdev-gpu_lockup) {
return true;
}
write_lock_irqsave(fence-rdev-fence_drv.lock, irq_flags);

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel