[PATCH][next] selftests/powerpc/dexcr: Fix spelling mistake "predicition" -> "prediction"

2024-05-08 Thread Colin Ian King
There is a spelling mistake in the help message. Fix it.

Signed-off-by: Colin Ian King 
---
 tools/testing/selftests/powerpc/dexcr/chdexcr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/dexcr/chdexcr.c 
b/tools/testing/selftests/powerpc/dexcr/chdexcr.c
index bda44630cada..c548d7a5bb9b 100644
--- a/tools/testing/selftests/powerpc/dexcr/chdexcr.c
+++ b/tools/testing/selftests/powerpc/dexcr/chdexcr.c
@@ -26,7 +26,7 @@ static void help(void)
   "\n"
   "The normal option sets the aspect in the DEXCR. The --no- 
variant\n"
   "clears that aspect. For example, --ibrtpd sets the IBRTPD 
aspect bit,\n"
-  "so indirect branch predicition will be disabled in the provided 
program.\n"
+  "so indirect branch prediction will be disabled in the provided 
program.\n"
   "Conversely, --no-ibrtpd clears the aspect bit, so indirect 
branch\n"
   "prediction may occur.\n"
   "\n"
-- 
2.39.2



[PATCH][next] tty: hvc: Remove second semicolon

2024-03-15 Thread Colin Ian King
There is a statement with two semicolons. Remove the second one, it
is redundant.

Signed-off-by: Colin Ian King 
---
 drivers/tty/hvc/hvc_xen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index 0e497501f8e3..388a71afd6ef 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -558,7 +558,7 @@ static void xencons_backend_changed(struct xenbus_device 
*dev,
break;
fallthrough;/* Missed the backend's CLOSING state */
case XenbusStateClosing: {
-   struct xencons_info *info = dev_get_drvdata(>dev);;
+   struct xencons_info *info = dev_get_drvdata(>dev);
 
/*
 * Don't tear down the evtchn and grant ref before the other
-- 
2.39.2



[PATCH][next] soc: fsl: dpio: remove redundant assignment to pointer p

2024-02-23 Thread Colin Ian King
There are two places where pointer p is being assigned a value that
is never read, the pointer is re-assingned later. The assignments
are redundant and can be removed.

Cleans up two clang scan build warnings:
drivers/soc/fsl/dpio/qbman-portal.c:662:3: warning: Value stored to 'p'
is never read [deadcode.DeadStores]
drivers/soc/fsl/dpio/qbman-portal.c:820:3: warning: Value stored to 'p'
is never read [deadcode.DeadStores]

Signed-off-by: Colin Ian King 
---
 drivers/soc/fsl/dpio/qbman-portal.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/soc/fsl/dpio/qbman-portal.c 
b/drivers/soc/fsl/dpio/qbman-portal.c
index 0a3fb6c115f4..03cc374f11d7 100644
--- a/drivers/soc/fsl/dpio/qbman-portal.c
+++ b/drivers/soc/fsl/dpio/qbman-portal.c
@@ -659,7 +659,6 @@ int qbman_swp_enqueue_multiple_direct(struct qbman_swp *s,
 
if (!s->eqcr.available) {
eqcr_ci = s->eqcr.ci;
-   p = s->addr_cena + QBMAN_CENA_SWP_EQCR_CI;
s->eqcr.ci = qbman_read_register(s, QBMAN_CINH_SWP_EQCR_CI);
s->eqcr.ci &= full_mask;
 
@@ -817,7 +816,6 @@ int qbman_swp_enqueue_multiple_desc_direct(struct qbman_swp 
*s,
full_mask = s->eqcr.pi_ci_mask;
if (!s->eqcr.available) {
eqcr_ci = s->eqcr.ci;
-   p = s->addr_cena + QBMAN_CENA_SWP_EQCR_CI;
s->eqcr.ci = qbman_read_register(s, QBMAN_CINH_SWP_EQCR_CI);
s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
eqcr_ci, s->eqcr.ci);
-- 
2.39.2



[PATCH][next] powerpc/selftests: Fix spelling mistake "EACCESS" -> "EACCES"

2023-12-15 Thread Colin Ian King
There is a spelling mistake of the EACCES error name, fix it.

Signed-off-by: Colin Ian King 
---
 tools/testing/selftests/powerpc/papr_sysparm/papr_sysparm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/papr_sysparm/papr_sysparm.c 
b/tools/testing/selftests/powerpc/papr_sysparm/papr_sysparm.c
index d5436de5b8ed..f56c15a11e2f 100644
--- a/tools/testing/selftests/powerpc/papr_sysparm/papr_sysparm.c
+++ b/tools/testing/selftests/powerpc/papr_sysparm/papr_sysparm.c
@@ -177,7 +177,7 @@ static const struct sysparm_test sysparm_tests[] = {
},
{
.function = set_with_ro_fd,
-   .description = "PAPR_IOC_SYSPARM_SET returns EACCESS on 
read-only fd",
+   .description = "PAPR_IOC_SYSPARM_SET returns EACCES on 
read-only fd",
},
 };
 
-- 
2.39.2



[PATCH][next] soc: fsl: dpio: remove redundant assignment to pointer p

2023-11-11 Thread Colin Ian King
The pointer p is being assigned a value that is never read, the assignment
is redundant and can be removed. Cleans up clang scan build warning:

drivers/soc/fsl/dpio/qbman-portal.c:662:3: warning: Value stored to 'p'
is never read [deadcode.DeadStores]

Signed-off-by: Colin Ian King 
---
 drivers/soc/fsl/dpio/qbman-portal.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/soc/fsl/dpio/qbman-portal.c 
b/drivers/soc/fsl/dpio/qbman-portal.c
index 0a3fb6c115f4..c2fa5c981edc 100644
--- a/drivers/soc/fsl/dpio/qbman-portal.c
+++ b/drivers/soc/fsl/dpio/qbman-portal.c
@@ -659,7 +659,6 @@ int qbman_swp_enqueue_multiple_direct(struct qbman_swp *s,
 
if (!s->eqcr.available) {
eqcr_ci = s->eqcr.ci;
-   p = s->addr_cena + QBMAN_CENA_SWP_EQCR_CI;
s->eqcr.ci = qbman_read_register(s, QBMAN_CINH_SWP_EQCR_CI);
s->eqcr.ci &= full_mask;
 
-- 
2.39.2



[PATCH][next] powerpc/powernv/sriov: perform null check on iov before dereferencing iov

2023-06-08 Thread Colin Ian King
Currently pointer iov is being dereferenced before the null check of iov
which can lead to null pointer dereference errors. Fix this by moving the
iov null check before the dereferencing.

Detected using cppcheck static analysis:
linux/arch/powerpc/platforms/powernv/pci-sriov.c:597:12: warning: Either
the condition '!iov' is redundant or there is possible null pointer
dereference: iov. [nullPointerRedundantCheck]
 num_vfs = iov->num_vfs;
   ^

Fixes: 052da31d45fc ("powerpc/powernv/sriov: De-indent setup and teardown")
Signed-off-by: Colin Ian King 
---
 arch/powerpc/platforms/powernv/pci-sriov.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-sriov.c 
b/arch/powerpc/platforms/powernv/pci-sriov.c
index 7195133b26bb..42e1f045199f 100644
--- a/arch/powerpc/platforms/powernv/pci-sriov.c
+++ b/arch/powerpc/platforms/powernv/pci-sriov.c
@@ -594,11 +594,10 @@ static void pnv_pci_sriov_disable(struct pci_dev *pdev)
struct pnv_iov_data   *iov;
 
iov = pnv_iov_get(pdev);
-   num_vfs = iov->num_vfs;
-   base_pe = iov->vf_pe_arr[0].pe_number;
-
if (WARN_ON(!iov))
return;
+   num_vfs = iov->num_vfs;
+   base_pe = iov->vf_pe_arr[0].pe_number;
 
/* Release VF PEs */
pnv_ioda_release_vf_PE(pdev);
-- 
2.30.2



[PATCH] selftests/powerpc: Fix spelling mistake "mmaping" -> "mmapping"

2022-10-21 Thread Colin Ian King
There is a spelling mistake in a perror message. Fix it.

Signed-off-by: Colin Ian King 
---
 tools/testing/selftests/powerpc/ptrace/core-pkey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/ptrace/core-pkey.c 
b/tools/testing/selftests/powerpc/ptrace/core-pkey.c
index bbc05ffc5860..1a70a96f0bfe 100644
--- a/tools/testing/selftests/powerpc/ptrace/core-pkey.c
+++ b/tools/testing/selftests/powerpc/ptrace/core-pkey.c
@@ -329,7 +329,7 @@ static int parent(struct shared_info *info, pid_t pid)
 
core = mmap(NULL, core_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (core == (void *) -1) {
-   perror("Error mmaping core file");
+   perror("Error mmapping core file");
ret = TEST_FAIL;
goto out;
}
-- 
2.37.3



[PATCH] selftests/powerpc/pmu: fix spelling mistake "mis-match" -> "mismatch"

2022-03-20 Thread Colin Ian King
There are a few spelling mistakes in error messages. Fix them.

Signed-off-by: Colin Ian King 
---
 tools/testing/selftests/powerpc/security/spectre_v2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/powerpc/security/spectre_v2.c 
b/tools/testing/selftests/powerpc/security/spectre_v2.c
index d42ca8c676c3..e832605442bb 100644
--- a/tools/testing/selftests/powerpc/security/spectre_v2.c
+++ b/tools/testing/selftests/powerpc/security/spectre_v2.c
@@ -183,7 +183,7 @@ int spectre_v2_test(void)
// These should all not affect userspace branch prediction
if (miss_percent > 15) {
printf("Branch misses > 15%% unexpected in this 
configuration!\n");
-   printf("Possible mis-match between reported & actual 
mitigation\n");
+   printf("Possible mismatch between reported & actual 
mitigation\n");
/*
 * Such a mismatch may be caused by a guest system
 * reporting as vulnerable when the host is mitigated.
@@ -201,14 +201,14 @@ int spectre_v2_test(void)
// This seems to affect userspace branch prediction a bit?
if (miss_percent > 25) {
printf("Branch misses > 25%% unexpected in this 
configuration!\n");
-   printf("Possible mis-match between reported & actual 
mitigation\n");
+   printf("Possible mismatch between reported & actual 
mitigation\n");
return 1;
}
break;
case COUNT_CACHE_DISABLED:
if (miss_percent < 95) {
printf("Branch misses < 20%% unexpected in this 
configuration!\n");
-   printf("Possible mis-match between reported & actual 
mitigation\n");
+   printf("Possible mismatch between reported & actual 
mitigation\n");
return 1;
}
break;
-- 
2.35.1



Re: [PATCH] crypto/nx: fix spelling mistake: "availavle" -> "available"

2017-11-14 Thread Colin Ian King
On 14/11/17 13:45, Julia Lawall wrote:
> 
> 
> On Tue, 14 Nov 2017, Colin King wrote:
> 
>> From: Colin Ian King <colin.k...@canonical.com>
>>
>> Trivial fix to spelling mistake in pr_err error message text
>>
>> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
>> ---
>>  drivers/crypto/nx/nx-842-powernv.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/nx/nx-842-powernv.c 
>> b/drivers/crypto/nx/nx-842-powernv.c
>> index f2246a5abcf6..9c01d11f255a 100644
>> --- a/drivers/crypto/nx/nx-842-powernv.c
>> +++ b/drivers/crypto/nx/nx-842-powernv.c
>> @@ -744,7 +744,7 @@ static int nx842_open_percpu_txwins(void)
>>
>>  if (!per_cpu(cpu_txwin, i)) {
>>  /* shoudn't happen, Each chip will have NX engine */
> 
> It could be nice to fix the comment as well: shoud -> should

Good point. V2 sent.
> 
> julia
> 
>> -pr_err("NX engine is not availavle for CPU %d\n", i);
>> +pr_err("NX engine is not available for CPU %d\n", i);
>>  return -EINVAL;
>>  }
>>  }
>> --
>> 2.14.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



Re: [PATCH] powerpc/pseries: fix spelling mistake: "Attemping" -> "Attempting"

2016-10-24 Thread Colin Ian King
On 24/10/16 23:20, Joe Perches wrote:
> On Mon, 2016-10-24 at 15:13 -0700, Kees Cook wrote:
>> On Mon, Oct 24, 2016 at 3:02 PM, Colin King <colin.k...@canonical.com> wrote:
>>> From: Colin Ian King <colin.k...@canonical.com>
>>>
>>> trivial fix to spelling mistake in pr_debug message
>>>
>>> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
>>> ---
>>>  arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c 
>>> b/arch/powerpc/platforms/pseries/hotplug-cpu.c
>>> index a1b63e0..c8929cb 100644
>>> --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
>>> +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
>>> @@ -553,7 +553,7 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, 
>>> u32 drc_index)
>>>  {
>>> int rc;
>>>
>>> -   pr_debug("Attemping to remove CPU %s, drc index: %x\n",
>>> +   pr_debug("Attempting to remove CPU %s, drc index: %x\n",
>>>  dn->name, drc_index);
>>>
>>> rc = dlpar_offline_cpu(dn);
>>> --
>>> 2.9.3
>>
>> Reviewed-by: Kees Cook <keesc...@chromium.org>
>>
>> scripts/spelling.txt should likely get an addition for "attemping". It
>> already has "attemps"...
> 
> There may not be enough of these to be useful and to my
> knowledge Colin isn't fixing comments

Indeed, I'm just using my kernelscan tool to scrape for errors in kernel
messages as these are seen by users as opposed to comments. Plus the
occurrences of the mistakes I'm finding are generally very small.

> 
> $ grep -rP --include=*.[ch] -wi "at+emp*t?ing" * | grep -vi attempting
> arch/x86/platform/uv/uv_nmi.c:/* Ping non-responding cpus attemping to force 
> them into the NMI handler */
> arch/powerpc/platforms/pseries/hotplug-cpu.c: pr_debug("Attemping to remove 
> CPU %s, drc index: %x\n",
> 



Re: [PATCH] powerpc/32: add missing \n at end of printk warning message

2016-09-12 Thread Colin Ian King
On 12/09/16 17:34, Joe Perches wrote:
> On Mon, 2016-09-12 at 11:12 +0100, Colin King wrote:
>> From: Colin Ian King <colin.k...@canonical.com>
>> The message is missing a \n, add it.
> 
> Was this found via inspection or a tool?
> 
grep


Re: linux-next: build failure after merge of the powerpc tree

2016-07-01 Thread Colin Ian King
On 01/07/16 06:27, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the powerpc tree, today's linux-next build (powerpc
> allyesconfig) failed like this:
> 
> arch/powerpc/kernel/fadump.c: In function 'fadump_invalidate_dump':
> arch/powerpc/kernel/fadump.c:1014:2: error: expected ';' before '}' token
>   }
>   ^
> 
> Caused by commit
> 
>   4a03749f140c ("powerpc/fadump: Trivial fix of spelling mistake, clean up 
> message")
> 
> I have added this fix patch for today:
> 
> From: Stephen Rothwell 
> Date: Fri, 1 Jul 2016 15:19:34 +1000
> Subject: [PATCH] powerpc/fadump: add missing semicolon
> 
> Fixes: 4a03749f140c ("powerpc/fadump: Trivial fix of spelling mistake, clean 
> up message")
> Signed-off-by: Stephen Rothwell 
> ---
>  arch/powerpc/kernel/fadump.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> index f0664860753e..b3a66d36 100644
> --- a/arch/powerpc/kernel/fadump.c
> +++ b/arch/powerpc/kernel/fadump.c
> @@ -1010,7 +1010,7 @@ static int fadump_invalidate_dump(struct 
> fadump_mem_struct *fdm)
>  
>   if (rc) {
>   pr_err("Failed to invalidate firmware-assisted dump 
> registration. Unexpected error (%d).\n", rc);
> - return rc
> + return rc;
>   }
>   fw_dump.dump_active = 0;
>   fdm_active = NULL;
> 

Apologies for that. Thanks for fixing it up.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: powerpc/fadump: trivial fix of spelling mistake, clean up message

2016-06-27 Thread Colin Ian King
On 27/06/16 12:20, Michael Ellerman wrote:
> On Mon, 2016-06-27 at 03:51 -0700, Joe Perches wrote:
>> On Mon, 2016-06-27 at 11:38 +0100, Colin Ian King wrote:
>>> On 26/06/16 05:19, Michael Ellerman wrote:
>>>> On Fri, 2016-24-06 at 17:43:00 UTC, Colin King wrote:
>>>>> trivial fix to spelling mistake "rgistration" and minor clean up
>>>>> of the printk error message
>>>> Can you also:
>>>>  - use pr_err()
>>>>  - unsplit the message, ie. keep the string all on one line.
>>> I can unsplit the string, but checkpatch will complain about that, so
>>> I'm not sure if that's preferred or not.
>>>
>>> WARNING: line over 80 characters
>>
>> If the statement is wrapped after the format,
>> then checkpatch shouldn't complain.
>>
>>  pr_err("Failed to invalidate firmware-assisted dump registration. 
>> Unexpected error (%d).\n",
>> rc);
> 
> But that's not actually any more readable, so just ignore checkpatch in this
> case IMHO. It's a guide, not the gospel.
> 
> cheers
> 
OK, so shall I'll send a V3 w/o the spit and the pr_err fix?
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: powerpc/fadump: trivial fix of spelling mistake, clean up message

2016-06-27 Thread Colin Ian King
On 26/06/16 05:19, Michael Ellerman wrote:
> On Fri, 2016-24-06 at 17:43:00 UTC, Colin King wrote:
>> From: Colin Ian King <colin.k...@canonical.com>
>>
>> trivial fix to spelling mistake "rgistration" and minor clean up
>> of the printk error message
> 
> Can you also:
>  - use pr_err()
>  - unsplit the message, ie. keep the string all on one line.

I can unsplit the string, but checkpatch will complain about that, so
I'm not sure if that's preferred or not.

WARNING: line over 80 characters

Colin
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/pseries/hvcserver: don't memset pi_buff if it is null

2015-10-12 Thread Colin Ian King
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 12/10/15 01:35, Daniel Axtens wrote:
> 
> Hi Colin,
> 
> This looks good. Out of curiousity, how did you find it? Code
> inspection? Bug? Static analysis?

static analysis with cppcheck. I forgot to mention that in the commit
message.

> 
> Not that it's particularly meaningful for such a trivial fix, but FWIW
:
> 
> Reviewed-by: Daniel Axtens <d...@axtens.net>
> 
> Regards,
> Daniel
> 
> Colin King <colin.k...@canonical.com> writes:
> 
>> From: Colin Ian King <colin.k...@canonical.com>
>>
>> pi_buff is being memset before it is sanity checked. Move the
>> memset after the null pi_buff sanity check to avoid an oops.
>>
>> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
>> ---
>>  arch/powerpc/platforms/pseries/hvcserver.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/platforms/pseries/hvcserver.c b/arch/powerp
c/platforms/pseries/hvcserver.c
>> index eedb645..94a6e56 100644
>> --- a/arch/powerpc/platforms/pseries/hvcserver.c
>> +++ b/arch/powerpc/platforms/pseries/hvcserver.c
>> @@ -142,11 +142,11 @@ int hvcs_get_partner_info(uint32_t unit_address
, struct list_head *head,
>>  int more = 1;
>>  int retval;
>>  
>> -memset(pi_buff, 0x00, PAGE_SIZE);
>>  /* invalid parameters */
>>  if (!head || !pi_buff)
>>  return -EINVAL;
>>  
>> +memset(pi_buff, 0x00, PAGE_SIZE);
>>  last_p_partition_ID = last_p_unit_address = ~0UL;
>>  INIT_LIST_HEAD(head);
>>  
>> -- 
>> 2.5.0
>>
>> ___
>> Linuxppc-dev mailing list
>> Linuxppc-dev@lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/linuxppc-dev

-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBCAAGBQJWG0/KAAoJEGjCh9/GqAImcV8QAIToDexS4X/vya3F8aHZ2qtT
idFEvgKl1mJxzgk79RJs874AiGs3CtOEC3/5w5fMh4eA/P6d6vJ1NPDu5bsugzzA
I6F329WP/QxeOWgU13GSXxa0p13sUxTXqFRT8sHqwDgEaecX6kR+nf8x+P5pZUYX
c7y25IHCZ/nNrj/QwQZcrlNd+U5bwxHyd5zUPJYYInbSEQmPUrhFhW1EkiUDVEYG
6rGmCzRGqfPS2sBqLXG/6ObP4FO8NC+bxQxNWAG/p9iWZg9KdIVL7IFTjWbxT7GC
dsVbBsWu7ewUqo6euK56cd5CFf0oFDoHwhbDQ7T9b9CHYvGVWHxW1k7rUCgcep9x
yJIIWOAVw78DemV3JkZm53Q2+1jUCYuaY6Vw8M3UmdQbWrg2rvbh8TtgoCiXbbrF
HlNO0wlFOBpmr7LoHEPoIV8TsIeoeEikGrXszkqXI/MXKvN8jW1k5vtzcD3j+EU9
gy9wZvovvVZ6RL0erXwVLdzDp+R2clQfIcSi/St2/OGW+5X9NXtuaa+mvBy+dcpW
Se0kO8DpLmHfNtcXvXJhCm77O1Oapw7s5UumevXSTibZ/Mhxzrdg+YhSWexm/SRu
evcm6pagTpX3Vruq4BTt0Rdji9J/stT8GFlOWT0hGH1ZBLrzIKTlkJskSTkT801N
+MkiI6UyL8lqdVoqZrNk
=xqJ4
-END PGP SIGNATURE-
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/3] drivers/ps3: Fix ps3-vuart null dereference

2015-09-14 Thread Colin Ian King
On the unlikely event that drv is null, the current code will
perform a null pointer dereference with it when printing a dev_dbg
message.  Instead, the BUG_ON check on drv should be performed
before we emit the dev_dbg message.

Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Geoff Levand <ge...@infradead.org>
---
 drivers/ps3/ps3-vuart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index d6db822..632701a 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -1000,12 +1000,11 @@ static int ps3_vuart_probe(struct ps3_system_bus_device 
*dev)
dev_dbg(>core, "%s:%d\n", __func__, __LINE__);
 
drv = ps3_system_bus_dev_to_vuart_drv(dev);
+   BUG_ON(!drv);
 
dev_dbg(>core, "%s:%d: (%s)\n", __func__, __LINE__,
drv->core.core.name);
 
-   BUG_ON(!drv);
-
if (dev->port_number >= PORT_COUNT) {
BUG();
return -EINVAL;
-- 
2.1.0


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] ps3-vuart: BUG_ON on null drv before dereferencing it on dev_dbg

2015-09-01 Thread Colin Ian King
On 01/09/15 11:35, Geert Uytterhoeven wrote:
> Hi Colin,
> 
> On Tue, Sep 1, 2015 at 12:21 PM, Colin King <colin.k...@canonical.com> wrote:
>> On the unlikely event that drv is null, the current code will
>> perform a null pointer dereference with it when printing a dev_dbg
>> message.  Instead, the BUG_ON check on drv should be performed
>> before we emit the dev_dbg message.
> 
> What about just removing the BUG_ON()?
> 
> The system will crash anyway, providing a backtrace.

I personally think a BUG_ON() shows intention to try to catch an
unexpected issue in a standard way as opposed to just removing it and
then hitting an issue with a null ptr deference.

> 
>> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
>> ---
>>  drivers/ps3/ps3-vuart.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
>> index d6db822..632701a 100644
>> --- a/drivers/ps3/ps3-vuart.c
>> +++ b/drivers/ps3/ps3-vuart.c
>> @@ -1000,12 +1000,11 @@ static int ps3_vuart_probe(struct 
>> ps3_system_bus_device *dev)
>> dev_dbg(>core, "%s:%d\n", __func__, __LINE__);
>>
>> drv = ps3_system_bus_dev_to_vuart_drv(dev);
>> +   BUG_ON(!drv);
>>
>> dev_dbg(>core, "%s:%d: (%s)\n", __func__, __LINE__,
>> drv->core.core.name);
>>
>> -   BUG_ON(!drv);
>> -
>> if (dev->port_number >= PORT_COUNT) {
>> BUG();
>> return -EINVAL;
> 
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev