All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* arch/powerpc/kernel/hw_breakpoint.c:176 task_bps_add() warn: passing a valid pointer to 'PTR_ERR'
@ 2020-09-09 15:51 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-09-09 15:51 UTC (permalink / raw
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6760 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Michael Neuling <mikey@neuling.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   34d4ddd359dbcdf6c5fb3f85a179243d7a1cb7f8
commit: 29da4f91c0c1fbda12b8a31be0d564930208c92e powerpc/watchpoint: Don't allow concurrent perf and ptrace events
date:   4 months ago
:::::: branch date: 21 hours ago
:::::: commit date: 4 months ago
config: powerpc-randconfig-m031-20200909 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
arch/powerpc/kernel/hw_breakpoint.c:176 task_bps_add() warn: passing a valid pointer to 'PTR_ERR'
arch/powerpc/kernel/hw_breakpoint.c:236 cpu_bps_add() warn: passing a valid pointer to 'PTR_ERR'

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=29da4f91c0c1fbda12b8a31be0d564930208c92e
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 29da4f91c0c1fbda12b8a31be0d564930208c92e
vim +/PTR_ERR +176 arch/powerpc/kernel/hw_breakpoint.c

29da4f91c0c1fbd Ravi Bangoria 2020-05-14  169  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  170  static int task_bps_add(struct perf_event *bp)
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  171  {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  172  	struct breakpoint *tmp;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  173  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  174  	tmp = alloc_breakpoint(bp);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  175  	if (IS_ERR(tmp))
29da4f91c0c1fbd Ravi Bangoria 2020-05-14 @176  		return PTR_ERR(tmp);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  177  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  178  	list_add(&tmp->list, &task_bps);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  179  	return 0;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  180  }
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  181  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  182  static void task_bps_remove(struct perf_event *bp)
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  183  {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  184  	struct list_head *pos, *q;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  185  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  186  	list_for_each_safe(pos, q, &task_bps) {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  187  		struct breakpoint *tmp = list_entry(pos, struct breakpoint, list);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  188  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  189  		if (tmp->bp == bp) {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  190  			list_del(&tmp->list);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  191  			kfree(tmp);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  192  			break;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  193  		}
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  194  	}
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  195  }
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  196  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  197  /*
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  198   * If any task has breakpoint from alternate infrastructure,
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  199   * return true. Otherwise return false.
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  200   */
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  201  static bool all_task_bps_check(struct perf_event *bp)
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  202  {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  203  	struct breakpoint *tmp;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  204  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  205  	list_for_each_entry(tmp, &task_bps, list) {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  206  		if (!can_co_exist(tmp, bp))
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  207  			return true;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  208  	}
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  209  	return false;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  210  }
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  211  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  212  /*
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  213   * If same task has breakpoint from alternate infrastructure,
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  214   * return true. Otherwise return false.
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  215   */
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  216  static bool same_task_bps_check(struct perf_event *bp)
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  217  {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  218  	struct breakpoint *tmp;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  219  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  220  	list_for_each_entry(tmp, &task_bps, list) {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  221  		if (tmp->bp->hw.target == bp->hw.target &&
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  222  		    !can_co_exist(tmp, bp))
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  223  			return true;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  224  	}
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  225  	return false;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  226  }
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  227  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  228  static int cpu_bps_add(struct perf_event *bp)
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  229  {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  230  	struct breakpoint **cpu_bp;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  231  	struct breakpoint *tmp;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  232  	int i = 0;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  233  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  234  	tmp = alloc_breakpoint(bp);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  235  	if (IS_ERR(tmp))
29da4f91c0c1fbd Ravi Bangoria 2020-05-14 @236  		return PTR_ERR(tmp);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  237  
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  238  	cpu_bp = per_cpu_ptr(cpu_bps, bp->cpu);
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  239  	for (i = 0; i < nr_wp_slots(); i++) {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  240  		if (!cpu_bp[i]) {
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  241  			cpu_bp[i] = tmp;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  242  			break;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  243  		}
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  244  	}
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  245  	return 0;
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  246  }
29da4f91c0c1fbd Ravi Bangoria 2020-05-14  247  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 31601 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* arch/powerpc/kernel/hw_breakpoint.c:176 task_bps_add() warn: passing a valid pointer to 'PTR_ERR'
@ 2021-04-14 15:08 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-04-14 15:08 UTC (permalink / raw
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6383 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Michael Neuling <mikey@neuling.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   50987beca096a7ed4f453a6da245fd6a2fadedeb
commit: 29da4f91c0c1fbda12b8a31be0d564930208c92e powerpc/watchpoint: Don't allow concurrent perf and ptrace events
date:   11 months ago
:::::: branch date: 13 hours ago
:::::: commit date: 11 months ago
config: powerpc-randconfig-m031-20210414 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
arch/powerpc/kernel/hw_breakpoint.c:176 task_bps_add() warn: passing a valid pointer to 'PTR_ERR'
arch/powerpc/kernel/hw_breakpoint.c:236 cpu_bps_add() warn: passing a valid pointer to 'PTR_ERR'

vim +/PTR_ERR +176 arch/powerpc/kernel/hw_breakpoint.c

29da4f91c0c1fb Ravi Bangoria 2020-05-14  169  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  170  static int task_bps_add(struct perf_event *bp)
29da4f91c0c1fb Ravi Bangoria 2020-05-14  171  {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  172  	struct breakpoint *tmp;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  173  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  174  	tmp = alloc_breakpoint(bp);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  175  	if (IS_ERR(tmp))
29da4f91c0c1fb Ravi Bangoria 2020-05-14 @176  		return PTR_ERR(tmp);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  177  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  178  	list_add(&tmp->list, &task_bps);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  179  	return 0;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  180  }
29da4f91c0c1fb Ravi Bangoria 2020-05-14  181  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  182  static void task_bps_remove(struct perf_event *bp)
29da4f91c0c1fb Ravi Bangoria 2020-05-14  183  {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  184  	struct list_head *pos, *q;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  185  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  186  	list_for_each_safe(pos, q, &task_bps) {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  187  		struct breakpoint *tmp = list_entry(pos, struct breakpoint, list);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  188  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  189  		if (tmp->bp == bp) {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  190  			list_del(&tmp->list);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  191  			kfree(tmp);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  192  			break;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  193  		}
29da4f91c0c1fb Ravi Bangoria 2020-05-14  194  	}
29da4f91c0c1fb Ravi Bangoria 2020-05-14  195  }
29da4f91c0c1fb Ravi Bangoria 2020-05-14  196  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  197  /*
29da4f91c0c1fb Ravi Bangoria 2020-05-14  198   * If any task has breakpoint from alternate infrastructure,
29da4f91c0c1fb Ravi Bangoria 2020-05-14  199   * return true. Otherwise return false.
29da4f91c0c1fb Ravi Bangoria 2020-05-14  200   */
29da4f91c0c1fb Ravi Bangoria 2020-05-14  201  static bool all_task_bps_check(struct perf_event *bp)
29da4f91c0c1fb Ravi Bangoria 2020-05-14  202  {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  203  	struct breakpoint *tmp;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  204  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  205  	list_for_each_entry(tmp, &task_bps, list) {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  206  		if (!can_co_exist(tmp, bp))
29da4f91c0c1fb Ravi Bangoria 2020-05-14  207  			return true;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  208  	}
29da4f91c0c1fb Ravi Bangoria 2020-05-14  209  	return false;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  210  }
29da4f91c0c1fb Ravi Bangoria 2020-05-14  211  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  212  /*
29da4f91c0c1fb Ravi Bangoria 2020-05-14  213   * If same task has breakpoint from alternate infrastructure,
29da4f91c0c1fb Ravi Bangoria 2020-05-14  214   * return true. Otherwise return false.
29da4f91c0c1fb Ravi Bangoria 2020-05-14  215   */
29da4f91c0c1fb Ravi Bangoria 2020-05-14  216  static bool same_task_bps_check(struct perf_event *bp)
29da4f91c0c1fb Ravi Bangoria 2020-05-14  217  {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  218  	struct breakpoint *tmp;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  219  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  220  	list_for_each_entry(tmp, &task_bps, list) {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  221  		if (tmp->bp->hw.target == bp->hw.target &&
29da4f91c0c1fb Ravi Bangoria 2020-05-14  222  		    !can_co_exist(tmp, bp))
29da4f91c0c1fb Ravi Bangoria 2020-05-14  223  			return true;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  224  	}
29da4f91c0c1fb Ravi Bangoria 2020-05-14  225  	return false;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  226  }
29da4f91c0c1fb Ravi Bangoria 2020-05-14  227  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  228  static int cpu_bps_add(struct perf_event *bp)
29da4f91c0c1fb Ravi Bangoria 2020-05-14  229  {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  230  	struct breakpoint **cpu_bp;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  231  	struct breakpoint *tmp;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  232  	int i = 0;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  233  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  234  	tmp = alloc_breakpoint(bp);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  235  	if (IS_ERR(tmp))
29da4f91c0c1fb Ravi Bangoria 2020-05-14 @236  		return PTR_ERR(tmp);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  237  
29da4f91c0c1fb Ravi Bangoria 2020-05-14  238  	cpu_bp = per_cpu_ptr(cpu_bps, bp->cpu);
29da4f91c0c1fb Ravi Bangoria 2020-05-14  239  	for (i = 0; i < nr_wp_slots(); i++) {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  240  		if (!cpu_bp[i]) {
29da4f91c0c1fb Ravi Bangoria 2020-05-14  241  			cpu_bp[i] = tmp;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  242  			break;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  243  		}
29da4f91c0c1fb Ravi Bangoria 2020-05-14  244  	}
29da4f91c0c1fb Ravi Bangoria 2020-05-14  245  	return 0;
29da4f91c0c1fb Ravi Bangoria 2020-05-14  246  }
29da4f91c0c1fb Ravi Bangoria 2020-05-14  247  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28732 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-14 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-14 15:08 arch/powerpc/kernel/hw_breakpoint.c:176 task_bps_add() warn: passing a valid pointer to 'PTR_ERR' kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-09-09 15:51 kernel test robot

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.